Archive for January, 2009

How To: File Checksum

Posted in Programming on January 5th, 2009 by Jason – Be the first to comment

In the past I have downloaded jquery, a javascript library, from google that I like to use when building different websites. When you go to download the file, it gives you a checksum, or value of numbers and letters, that is used to verify the integrity of a file. Usually I dont pay any attention to the checksum value because I am never too worried about it not downloading correctly but mainly because I didnt know how to use a checksum.

A quick google search turned up step by step instructions on how to verify the checksum on a Mac computer. Here is the link: http://www.bresink.de/osx/sha1.html.

Since I am running OS X.4 all of my downloads go staight to my desktop so used a slightly different process.

  1. Open Terminal
  2. Change to your Desktop (Only if file to check is on desktop) (cd Desktop)
  3. Type the following command (openssl sha1 filenamehere)

Thats all there is to it. There are a couple things you should note. First of all this is for an sha1 checksum. Usually if you download a file that has a checksum, it should be listed with the file what the encryption type used is. If it is different than sha1 you would just need to change it in step 3 to the specified encryption. Also, if your file is not located on the desktop, then like the steps in the link, you can just drag and drop into the terminal window.

Post to Twitter Tweet This Post

Reuse your Select statements with mysql_data_seek( )

Posted in Programming on January 2nd, 2009 by Jason – Be the first to comment

This function has come in very handy with the developement of this site. You can use this function to set the data pointer to a certain row within your result that you recieve from a database function, in my case, mysql_query().

There are a couple reasons you would want to use the mysql_data_seek(). One would be to return to the first row returned from the database, or it could be used to return to any row. There are also other uses for this function but to keep it simple I will just talk about the first.

The following code is a standard mysql query created by dreamweaver.

mysql_select_db($database, $connection);
$query="SELECT * FROM tables;
$resource=mysql_query($query, $connection) or die(mysql_error());
$row_recordset= mysql_fetch_assoc($resource);
$totalRows_recordset = mysql_num_rows($resource);

When you request information from the database it is stored as a resource. You can then pull from that resource with the mysql_fetch_assoc($resource). You can also use other functions such as mysql_fetch_row($resource).

PHP handles a resource very similar to reading a file. As PHP reads from the resource, it marks its place, much like earmarking a page in a book PHP remembers the last spot that was read from the resource. When you get to the last page of the book, you turn back to page one, and when you get to the last of the resource you have to set the pointer back to the beginning.

mysql_data_seek("$resource",0);
$row_recordset=mysql_fetch_assoc($resource);

The mysql_data_seek() uses two values to accomplish this.The first value “$resource” is exactly what it says it is, the resource of your mysql select statement. The second is a numeric value of where you want to move the pointer or bookmark for that resource. The next time you get a value from the resource it will be from the new location of the pointer.

An important note if you are using dreamweaver. As you saw earlier in the code, dreamweaver initially sets $row_resource. With it initially set, you can use a do while loop so that the first instance is set and each reoccurring instance is set by the while statement. This is why after using the mysql_data_seek, I re-assigned $row_resource with the next value after the dataseek, in this case setting it back to the first value from the mysql select statement.

Post to Twitter Tweet This Post

New Year, 2009

Posted in Ramblings on January 1st, 2009 by Jason – Be the first to comment

Now that 2009 is officially here it’s that time to think about what to do differently. I am usually not big on the resolutions but this year I have a couple things that I would like to do better. One thing I would like to work on is the amount of design work that I do. I will be trying to create website layouts more often to impove my design ability. My goal is to try and create a new layout once every three months to help me increase my abilities and skill level. Although it doesnt sound like much, once you add in going to college full time with a part time job, and spending time with my wife, and my personal programming projects, one layout every three months will be plenty for me.

I also am planning on posting a little more regualarly, but we will see how well I can do with that.

Post to Twitter Tweet This Post