Simple PHP script for unzip function

Here’s a simple PHP function to unzip a ZIP file and retain directory structure – great for use when you can’t use exec(). The function will return false on error and true on success. Call it with the following code:

if (unzip('../'))
	echo 'Cool, it worked!';
	echo 'Uh oh, something went wrong.';
function unzip($zipfile) {
	$zip = zip_open($zipfile);
	if ($zip) {
		while ($item = zip_read($zip)) {
			$name = zip_entry_name($item);
			if (substr($name, -1) == '/') {
				if (!file_exists($name)) {
					$dir = mkdir($name);
					if (!$dir) {
						return false;
			} else {
				if (zip_entry_open($zip, $item, "r")) {
					$f = file_put_contents($name, zip_entry_read($item, zip_entry_filesize($item)));
					if ($f === false) {
						return false;
				} else {
					return false;
		return true;
	return false;

How to Duplicate Database Rows in MySQL

If you're looking for a quick, easy way to duplicate a MySQL Row, try the following example:

		(Col2, Col3, ...)
		(Col2, Col3, ...)
	FROM Tbl1
		WHERE Col1 = 1;

This example assumes you want to duplicate the row where Col1 equals 1. You could change the where clause to anything for that matter. However, if there are more than one rows selected from the SELECT statement, it will INSERT each row, not just one.

Likewise, you could duplicate a whole MySQL table using the following:

		(Col2, Col3, ...)
		(Col2, Col3, ...)
	FROM Tbl1;

How to mount Amazon EC2 EBS volume on an instance’s file system

The following assumes you have created a volume in AWS Management Console and attached it to your instance as /dev/sdh.
A brand new volume is unformatted block storage.  It shows up as another device, but doesn’t contain a filesystem.  (An EBS volume that previously had a filesystem created on it won’t be mounted either by the attachment process).
You can verify that your instance can see the EBS volume by running the following command on the instance:
cat /proc/partitions
You’ll see an entry for sdh.  At this point, you should create a filesystem and mount it manually.  You could create an EXT3 filesystem on the device and then mount it on ‘/mnt/ebs’ with the following commands, (run as root):
mke2fs -F -j /dev/sdh
mkdir /mnt/ebs

mount /dev/sdh /mnt/ebs 

Android 1.6 Version Update (Donut) adds new Power Control Widget

I’m a developer and have made a few apps for android, so I updated to the newest SDK today, Android 1.6, named "Donut". It’s supposed to roll out in October.

One of the first new things I noticed was a nifty power control widget, which gives you the ability to quickly toggle wifi, bluetooth, gps, data syncing, and brightness. Not a particularly big deal, because I’m currently using worthy widgets downloaded from the market, but it’s nice to have it natively for sure. Still waiting on a 3g toggle though…


Classic ASP: More Efficient Database Recordset, GetRows() XoiseRecordset

I’ve created what I believe to be a more efficient recordset object for traversing rows returned from a database query. I implemented all methods/properties that I feel make sense to implement. There’s definite room for improvement, but it’s a good start. My reasoning for creating this is that I like the functionality of using recordsets (via Server.CreateObject("ADODB.Recordset")), but there is a HUGE drawback in that it is horrible on the database. The Server.CreateObject approach makes a database call every time a EOF, BOF, or a traversal method (ie. MoveNext, MovePrevious, etc.) is called.

My fix is to use the GetRows() method to return it as a multidimensional array and just implement my own class with the same (or similar) functionality. There is also an advantage to using this Recordset over just plain using the GetRows() method. I went ahead and implemented a way to extract the column names from the query, which allows you to grab the information using the column name, instead of the index of the array (ie. objRS("Column_Name")). You may also access the data using the column index if you prefer. Note that I haven’t implemented support for "SELECT * FROM Tbl…" syntax, so you’ll HAVE to use the index for this.

There is one main usage difference to note. Rather than opening the recordset with .Open SQL_String, Connection_Object, you must individually update the .Conn and .SQL properties. I’ll most likely change this if there is enough interest and I create a newer version. If I do that, I’ll most likely provide cache support.

Download: (1.29KB)


Retrieve Data:

  • objRS("Column_Name")
  • objRS.Item("ColumnName")
  • objRS.Row(0)

Implemented Methods/Properties:

  • Conn
  • SQL
  • EOF()
  • BOF()
  • MoveNext()
  • MoveFirst()
  • MoveFirst()
  • MoveLast()
  • Move()
  • GetRows()
  • RecordCount()
  • PageCount()
  • PageSize()
  • AbsolutePage()
  • AbsolutePosition()

The Gratitude Campaign

This is obviously an aside to the web tools I usually post about.

As the son of a 20+ year, 3 time war Army vet and brother of a ROTC cadet, I feel the need to help spread the word about a new effort to show our gratitude for our brave armed forces.

From an email I received:

Have you ever seen one of our military walking past you and wanted to convey
to them your thanks, but weren’t sure how or it felt awkward?

Recently, a gentleman from Seattle created a gesture which could be used and
has started a massive movement to get the word out.

Please everybody take just a moment to watch…. The Gratitude Campaign
…and then forward it to your friends!

Click on below.

Valid Google PageRank for each server

DigPageRank LogoI just thought I’d share the site wholesale jerseys that I use to find my sites’ PR. I cheap nba jerseys use DigPageRank. The site wholesale mlb jerseys is a very useful tool. The Obviously, there are a wholesale jerseys lot of PR tools etc. out Generator there, but I find this Through one particularly Thanh useful because it’s simple and Freelance it returns results from multiple servers, which can be useful in verifying it’s validity – which is also another cheap nba jerseys nice feature that the site boasts.