Stephen J. Fuhry

Software Developer

Summary

I am a software developer in Cleveland, OH, and a recent graduate of John Carroll University with a B.A. in Philosophy. I have also taken coursework in Computer Engineering at Cleveland State University.
I am particularly interested in developing economically efficient applications to manage workflow using Free Software for medium-sized businesses.

Projects

Montmere Limited: Consulting firm providing custom software applications to business clients; cofounder, partner.

FindaCatholicMass.com: Map and modify data on over 100,000 Catholic churches around the world wiki-style; creator.

Welcome to my new blog!

Posted on March 31, 2009, 7:59 pm

This will replace theSteveBlog as soon as I get around to figuring out how to embed WordPress stuff better, and after I move all my old posts.

Until then, enjoy the fun jQuery stuff, and use Linux!

Cheers!

PHP’s mysqli, and mysqli_real_escape_string()

Posted on March 29, 2009, 7:12 pm

I used to use $newValue = addslashes($newValue) when inserting data into MySQL and $currentValue = stripslashes($currentValue) when pulling it out. Then a week or so ago, I discovered mysqli_real_escape_string().

Seriously, start using it because then you don’t have to ever do $currentValue = stripslashes($currentValue) when pulling data out.

Here’s the procedural way of doing it (just took it right out of the docs):
$link = mysqli_connect(“localhost”, “my_user”, “my_password”, “world”);
$newValue = mysqli_real_escape_string($link, $newValue);

And here’s the object oriented way of doing it (less verbiose and just as clear — I prefer this method).
$db = new mysqli(“localhost”, “my_user”, “my_password”, “world”);
$newValue = $db->real_escape_string($newValue);

The only thing that bothers me is that there is no reason they couldn’t just have called the function mysqli_escape (.. crossed out just incase.) I mean really, that’s one of those functions that there is no way out of having to use it (at times) every line for 20 lines of code.

jQuery login without refresh

Posted on March 22, 2009, 7:47 pm

I have spent a lot of time recently writing javascript, and I recently discovered jQuery. It is pretty much amazing. Here’s a super easy thing I wrote to use jQuery’s ajax stuff to log in a user without refreshing the page:

1). login.js

function logMein() {
var username = $(”#usernameId”).val();
var password = $(”#passwordId”).val();
$.post(”./login.php”, { username: username, password: password }, function(welcome) { $(”#loginDiv”).html(welcome); } );
}

2). element to get jQuery:

<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js”></script>

3). put <div id="loginDiv"><?php require_once(’login.php’); ?></div> where you want to have the login thingy

4). login.php

@session_start();

require_once(’class/user.class.php’);
// checks to see if user submitted form stuff, if yes, tries to login
if (isset($_POST['username']) && strlen($_POST['password']) >= 6) {
$username = &$_POST['username'];
$password = &$_POST['password'];
$userLogin = new User($username);
if ($userLogin->getExists() === TRUE && $userLogin->passwordMatch($password) === TRUE ) {
$_SESSION['username'] = $username;
}
}
// if user has been logged in successfully, say welcome, else rewrite form

if (isset($_SESSION['username'])) {
$userObj = new User($_SESSION['username']);
$userInfo['id'] = $userObj->getId();
$userInfo['username'] = $userObj->getUsername();
$userInfo['firstName'] = $userObj->getFirstName();
$userInfo['lastName'] = $userObj->getLastName();
$userInfo['email'] = $userObj->getEmail();
$userInfo['city'] = $userObj->getCity();
$userInfo['state'] = $userObj->getState();
$userInfo['country'] = $userObj->getCountry();
echo “Welcome “.$userInfo['firstName'].”! “;
echo “Logout“;
} else {
?>
<script type=”text/javascript” src=”http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js”></script>
<form name=”login” action=”" onsubmit=”return false” method=”post”>
username:<input type=”text” id=”usernameId” name=”username” maxlength=”50″ value=”" />
password:<input type=”password” id=”passwordId” name=”password” value=”" />
<input type=”submit” id=”submitLogin” value=”Login” onclick=”logMein();” />
</form>

}
?>

MS SQL datetime to Unix Timestamp

Posted on March 21, 2009, 11:25 am

Here’s a quick, easy, and painless way in PHP to convert MSSQL’s nasty datetime format to a nice Unix Timestamp:

$MSSQLdatetime = “Feb 7 2009 09:48:06:697PM”;
$newDatetime = preg_replace(’/:[0-9][0-9][0-9]/’,”,$MSSQLdatetime); // strip fractional seconds
$time = strtotime($newDatetime);
echo $time.”\n”;

Just did it for 4 columns in ~110,000 rows, (a little less than half a million times) and it seems to have worked just dandy.

Backup MySQL to Gmail using PHP

Posted on March 18, 2009, 11:41 pm

Yesterday I rewrote a cool script to backup a MySQL database to a Gmail account using PHP.

The original source came from here, but I ended up rewriting over half of it because it did not work on our servers, and there was some other stuff that I did not like.

The script uses mysqldump to get a dump of your db, archives it, and emails it as an attachment to your gmail account. Remember, gmail has a 20mb limit on attachments.. but for most small sites that is more than you’ll ever need.

Here’s the rundown on how to use it:

1) Register a Gmail account to backup your db to.
2) Get these three files: mysql2gmail.php, class.phpmailer.php, class.smtp.php

wget http://dl.getdropbox.com/u/113063/mysql2gmail.php http://dl.getdropbox.com/u/113063/class.phpmailer.php http://dl.getdropbox.com/u/113063/class.smtp.php

3) Change the stuff on the top of mysql2gmail.php until it works.

PHP vs Python

Posted on February 25, 2009, 9:33 pm

For better or for worse, I am far more proficient in PHP than Python. However, when it comes down to syntax, I would much prefer to write in Python.

I love the simplicity of Python; I tend to make fewer mistakes with its eye-friendly syntax. Although, at this point, I am so familiar with PHP’s C-like syntax, that I can sometimes write 100+ lines of code without a single syntax error (and I don’t use your silly error-correcting IDEs, but vi with only basic syntax highlighting on the command line).

Anyways, I have been writing several hundred lines of PHP daily for the past week or so, and I just can’t get over how amazing PHP’s official documentation is over Python’s.

When I am trying to figure out how to do something new in Python, especially if it involves using libraries I am not familiar with already, I have to go through all kinds of hell googling around to find decent documentation on it. However, with PHP, just type in php.net/some_function or php.net/variables or whatever, and you not only get what you are looking for, but also a very smart list of similar functions / information as what you are viewing.

If I could go back and teach my 13yr old self how to code again, I would use Python because it is sane, scalable, and very efficient. But if I needed to assign my 13yr old self a project to complete, I would have him use PHP, because he could actually figure out how to do it.

Python Script to Send SMS via Gmail

Posted on February 19, 2009, 1:31 am

Recently I wrote this little script to send a text message to my phone using my Gmail account. It uses a python library called libgmail. (Debian / Ubuntu package: python-libgmail should do the trick).

My cell carrier is Alltel — you’ll have to change myCellEmail to match that of your carrier (list provided courtesy of wikipedia).

#!/usr/bin/env python
import libgmail

stuff = libgmail.GmailAccount(”me@gmail.com”, “password”)
myCellEmail = “1234567890@message.alltel.net”

stuff.login()
msg=libgmail.GmailComposedMessage(myCellEmail, “”, “Hello World! From python-libgmail!”)
stuff.sendMessage(msg)

Cheers!

Feast of the Immaculate Conception

Posted on December 8, 2008, 10:47 pm

I snapped this photo today of the elevation of the Host at Immaculate Conception in Cleveland (map). Today was the Patronal feast of the parish, and they had a beautiful liturgy in the usus antiquior with two priests as subdeacons.

Advent (6 days away!)

Posted on November 24, 2008, 2:54 pm

I have often wondered why Advent, unlike Lent, is not considered a time of fasting in the Roman Rite. For most Eastern Catholics, it is like a mini-Lent in many respects — after all, we are preparing for the coming of our Lord.

As good as fasting is, perhaps it is for the best. I can relate to Flannery O’Connor who said in a letter to a man reviewing one of her novels,

“I have 50 or 60 pages on the [new] novel but I still expect to be a long time at it. It’s a theme that requires prayer and fasting to make it get anywhere. I manage to pray but am a very sloppy faster.” (The Habit of Being, p. 59)

So in the spirit of a Western Advent, here is a good drinking song written by everyone’s favorite militant Catholic, Hilaire Belloc. This is from his excellent little novel, “The Four Men.” There are several other good drinking songs scattered througout that book along with the notation.

[Audio]
Noël, Noël, Noël, Noël
A Catholic tale have I to tell,
and a Christian song have i to sing,
while all the bells in Arundel ring

I pray good beef and I pray good beer
this holy night of all the year
but I pray detestable drink to them
that give no honor to bethlehem

May all good fellows that here agree
drink audit ale in heaven with me
and may all my enemies go to hell,
Noël, Noël, Noël, Noël
May all my enemies go to hell,
Noël, Noël

Funeral Arrangements for Giselle Updegraff

Posted on November 18, 2008, 9:56 am

I just received an early word on funeral arrangements for Giselle Updegraff:

Wake:
Friday, Nov 21, 1-3pm & 5-9pm
Ritondaro funeral home, 126 South Street, Chardon, OH

Funeral: Saturday, Nov 22, 11am
St. Helen Church, Newbury OH
Also, there will be a viewing at St. Helen’s before the funeral from 9-10:45am

Edit (19 Nov 08 11:45am): More info has been posted here.

Requiem æternam dona eis, Domine;
In memoria æterna erit justus,
ab auditione mala non timebit.

Domine, Jesu Christe, Rex gloriæ,
libera animas omnium fidelium defunctorum
de pœnis inferni et de profundo lacu.
Libera eas de ore leonis,
ne absorbeat eas tartarus,
ne cadant in obscurum;
sed signifer sanctus Michæl
repræsentet eas in lucem sanctam,
quam olim Abrahæ promisisti et semini ejus.

Hostias et preces tibi, Domine,
laudis offerimus;
tu suscipe pro animabus illis,
quarum hodie memoriam facimus.
Fac eas, Domine, de morte transire ad vitam.
Quam olim Abrahæ promisisti et semini ejus.

Filed under: Uncategorized by Stephen J. Fuhry
No Comments »
Name:

Email:

Message: