Archive for May, 2007

Resume Unknown Screen

Wednesday, May 23rd, 2007

Sometimes you know that there is an instance of an application running in a screen but you are not sure about the exact screen name and

screen -x

returns a tedious list. Maybe I still have no clue about how to use screen to the fullest, but here is a function I use in a script on my shell account to resume screens:

(more…)

Generating Random Passwords

Monday, May 21st, 2007

Writing a sufficient password generator does not have to be hard nor overly complex. In this article a simple password generator technique will be presented and explained.

One of the simplest password generators could simply output the ASCII character represented by a series of random integers:

(more…)

Youtube Ripping: Reloaded

Sunday, May 13th, 2007

The initial version of the Youtube command-line ripper appeared on Digg without ever reaching any sort of maturity. There was at most an hour between the beginning of the coding process and the massive public exposure. I am grateful for all the feedback I have received and, as promised I now announce a total rewrite in PHP that is confirmed working on Linux, Windows and OS X (just about any platform with PHP actually).

Version 0.40 is available for download.

Considering going to bed after…

Sunday, May 13th, 2007

Considering going to bed after finishing http://tinyurl.com/2g8slh

Handling Command Line Arguments in PHP

Saturday, May 12th, 2007

When working with PHP in an web environment programmers are often used to the comfort of having the associative arrays $_GET and $_POST to hold the data to be passed on as arguments. During command line runtime however, there is only a numerated array called $argv holding each argument:

(more…)

An Object Oriented Caching Approach

Tuesday, May 8th, 2007

Today I announce a minor release of my latest object oriented beauty. Inspired by the earlier mentioned caching method in PHP i decided to rewrite it as a reusable class.

SimpleCacher is a class written in PHP aimed at providing an object oriented caching method for (X)HTML-pages otherwise generated by querying a database-backend along with the execution of intense PHP applications. The idea is to provide a clean and extendable way to set up caching procedures for webpages.

  • GZIP compressed cache (sends the GZIP compressed cache file directly to the client, if possible)
  • Strips down the cache file to contain only a single line of (X)HTML
  • Redundant error checking forces the original content to be displayed in case the cache method breaks

Simple Caching Method Using PHP

Sunday, May 6th, 2007

The idea of caching is to keep a replicate of data where it is easier to reach than the original. Simply put caching could mean to keep a static copy of a web page that would otherwise be compiled together using a dynamic procedure (like PHP using a database back-end). By caching a copy to be served statically the overhead the dynamic procedure would otherwise create is eliminated.

A very simple cache procedure would consist of checking if there is already a cached copy of the requested material, if there is no already cached copy then it should create one. The second thing to take into consideration is how ‘fresh’ the currently cached copy is, all file systems today keep track of modification times on each file, comparing timestamps is sufficient enough for this. This very simple example does the previously mentioned checks and comparisons and you can try it out by accessing a cached copy of this post.

Since there is still some overhead when the client has to load the CSS and associated images the bandwidth saving is non-existent, the database load is totally eliminated however. I intend to work further on this caching code and make it object oriented and later on figure out how to make it save some bandwidth as well as database queries and execution time.