3.6 Ghz Dual Core Uber-Computer: $600

May 27th, 2009 by Peter Anselmo 1 comment »

I recently put together a new server, and as preparation, spent a few hours on Newegg.  I’m quite suprised at some of the deals that can be found right now, and thought I would pass the summation of my research on.  Behold: The Best Computer for your Money (as of May 2009).

Case: Antec 300
Power Supply: Antec Basiq 500
(Buy these together on Newegg & Save $20)

Motherboard:Gigabyte GA-EP45C-UD3R
CPU: Intel E8400 3.0 Ghz Core2Duo (Wolfdale)
(Buy these together on Newegg & Save $15)

CPU Cooler: Zalman 9500

Memory: 4GB Corsair XMS

Video Card: BFG 9800 GT OC 1GB

Hard Drive: Seagate 500GB SATA

There you have it folks.  All told, the total in my newegg cart for all of the above is $651.88.  There’s also another $35 off in Mail-in Rebates, bringing the total to $626.88.  Now here’s the beautiful thing.  The combination of the 45nm CPU and the beefy cooler allow even a newb to overclock the CPU to 3.6 Ghz without trouble.

Here’s are some of the highlights:
3.6Ghz Dual Core Processor
6MB L2 CPU Cache
1333 Mhz Front Side Bus
4 GB Ram with super-fast 5-5-5 timings
1GB Video card

Try to find those specs with any pre-built machine; you won’t.  And if you do, it won’t be with the quality, name-brand guts you see here.  That’s all for now, I’m off to play UT3.

The Sticky Bit

January 20th, 2009 by Peter Anselmo No comments »

Just about any linux user is familiar with the unix permission system. You have three categories of users (user, group, other) and three different permission options (read, write execute). However, most users don’t know about several advanced permissions, one of which is the sticky bit.

Besides having a cool name, the sticky bit provides a very useful function: when set as a directory permission it lets anyone add things the the directory (write access), but they can only delete things they own. Normally, allowing all users write access also allows all users to delete anything (yeah, that’s dangerous).

In particular, users can only remove files if at least one of the following is true:
-The user is the owner of the file
-The user is the owner of the parent directory
-The user has write permissions on the file

When is this useful? It’s commonly found in var directories, when everyone needs to be able to create files, but shouldn’t modify files for other users. It’s also common in mailbox directories for the same reason. I found it particularly useful for a media folder that is shared between users. Users can add Pictures and Videos to the folder, but can’t delete those belonging to others.

So how do you set it?
-For chmod in relative mode, the sticky bit is designated by a “t”

# chmod t filename

-For chmod in absolute mode, the sticky bit can be added by prepending a “1” the the permission.

#chmod 1777 dirname

Cool huh?

You Cannot Pass

December 29th, 2008 by Peter Anselmo 1 comment »

I stumbled across this image online.  I couldn’t resist re-posting it.

You Cannot Pass

Dynamic Display of the Alphabet with PHP

December 23rd, 2008 by Peter Anselmo No comments »

Here’s a neat trick I recently used: Say you want to the display the alphabet on your web page.  The most likely scenario being for paging links to organize a directory of people or businesses. PHP has a chr() function, which displays the ASCII character for any given integer.

Rather than looping through an array with 26 values, or worse yet, typing out 26 lines of code, just loop through the display code 26 times.

<?php
for ($i=65; $i<=90; $i++) {
 echo chr($i);
}
?>

For those not familiar with ASCII mappings, values 65-90 represent the uppercase letters A-Z. Alternately, you could use the values 97-122 for lowercase a-z.  If you wanted to mix the two (say to display uppercase, but use lowercase in the link) just use the strtoupper() or strtolower() functions inside the loop.  Here’s a more applicable sample:

<?php
for ($i=97; $i<=122; $i++) {
 $x = chr($i);
 echo '<a href="memberlist.php?alpha=' . $x . '>' . strtoupper($x) . '</a>';
}
?>

You can see an example of both applied here.

Coding Music

December 10th, 2008 by Peter Anselmo No comments »

Music is a big part of programming.  Nothing gets me zen faster than immersion in a good back beat.  As such, I’d like to pass on a few genres and artists that I think stand out as being conducive to cranking out code.

Trance:

Eric Jordan

Eric Jordan

By far, I spend the most time listening to Eric Jordan.  His trance mixes are stunning.  They are always creative, drawing from his vast knowlege of obscure, but impressive tracks.  He is a master at creating a mood, evoking emotion, and pulling the listener in.  Every month he posts a new mix on his website: neverrain.com, available for free to download.  His mixes tend to have more subtle melodies, and less vocals, so I find them extra conducive to zoning out and programming complex algorithms.

asd

Vocal Trance:

DJ GT

DJ GT

DJ GT takes a similar approach, creating hour long mixes and posting them for free on his website, generationtrance.com. He is equally talented, although his track lists tend to be slightly more mainstream.  All of the songs he uses contain lyrics, which makes the mixes a little more structured and digestable for those not as used to electronic music.  I’ll throw one of his many tracks in the queue when I want something more upbeat to tap my feet to.

asd

Psycadelic Trance:

Shpongle

Shpongle

Shpongle is group out of the UK that defies description.  Generally, I’d label it Psy Trance, but you’ll find heavy influences of world beat, classical, opera, jazz, ska, punk, dub, and half a dozen other genres.  It all adds up to 100% awesome.  Lyrics in their music are not arranged into verses to tell a story, but rather sampled to become part of the ambience and reinforce the mood.  My only wish is that they had more than three albums.

asd

Dub:

O.T.T.

OTT

If I had to describe Dub to someone who hadn’t heard it, I’d label it the offspring of Reggae and Trance.  It’s characterized by a slower tempo than most electronica, with a heavier bassline and more emphasis on the ambience of the music.  Ott’s first album Blumenkraft stands out as my favorite mix of any artist mentioned here.  It’s simply the most powerful weapon against the drone of office background noise I’ve found.  I save it for when I need to write that recursive function I’ve been putting off all week.

asd

Industrial:

Front Line Assembly

Front Line Assembly

Two of my favorite artists are Bill Leeb and Rhys Fulber.  They’ve been making electronic music for two decades, and they’ve made some of the best.  They’ve gone under several different names, the most popular being Delerium and Front Line Assembly.  Delerium, like Shpongle, defies description and has gone through several distinct transitions through the years.  I own and love the entire collection, but the music I find best to program to however, are their oldest albums, found here and here.  Each of those are a two CD set that compiles all the their earliest releases which are (sadly) no longer available.  The music is very experimental, and it laid the groundwork for the industrial genre.

Well, that concludes the tour of my favorite programming music.  I hope you enjoyed the trip; be careful opening the overhead bins, as items may have shifted in flight.  I’m always open for recommendataion, so if you hear a good tune that makes you stop and close your eyes to listen, let me know.

The Zen of CSS Design

December 7th, 2008 by Peter Anselmo 1 comment »
The Zen of CSS Design

The Zen of CSS Design

I recently finished The Zen of CSS Design. The book has a good display of creative website designs, and it’s good for providing inspiration. It organizes the content in an interesting way, where each chapter focuses on a single aspect of desgn: ie, layout, imagery, typography, etc.  Within each chapter, individual designs are dissected and evaluated as they apply to these design principles.

Unfortunately, I found much of the text to be cheesy and repetitive, not unlike what you would stick in a history paper to reach the word count your teacher asked for.  The author is at times ambiguous, and at other times attempts to wax poetic.

It suffers from an identity crisis that many web books do: It moves too fast for the beginner, and re-hashes the basics too much for the experienced. Myself being in the latter camp, and my eyes start to glaze over when I read how to use a “background-image” or “border” property.

Also, with many CSS books, it fails to acknowledge when compromises are necessary. There are times when it’s just plain better to use JavaScript or tables. As a working web developer with deadlines and budgets, you don’t have the luxury (burden?) of creating 10 lines of CSS and 3 divs just to avoid using a little 2 cell table.

Overall, I’m glad to have the book, but mostly for the eye candy rather than what it has to say.

Turning off the Terminal Beep

December 5th, 2008 by Peter Anselmo No comments »

I use the VIM editor.  Alot.  That means that I get beeped at.  Alot.  As a note to those who haven’t used VIM, it beeps through the system speaker, not your normal speakers.  The system beeper is an especially annoying relic, leftover from two decades ago when a system beep was actually useful. I’d finally had enough, so I figured out how to turn it off.  It turns out that (like everything else) it’s extremely easy in Ubuntu.

System -> Preferences -> Sound -> System Beep -> Enable System Beep

I unchecked that puppy, and now my computer my computer doesn’t make a sound (except of course, the hum of 8 fans pushing 1,000cfm of air across my OC’d mobo).

PHP Month View Calendar

December 3rd, 2008 by Peter Anselmo No comments »

I recently had to develop a month view Calendar for a website I’m building.  While such a thing is very common, it presents a number of twists:

  • You can’t start it on the first of the month – The first will likely fall mid-week
  • To find the acutual first day of the week, you need to know how many days are in the previous month and count backwards
  • You cannot assume 4 weeks per month -most have 5 or 6
  • you will need to use the correct number of days in the month, and then add on the correct number of days of the next month to finish the week

After playing with a few algorithms, I decided to represent the month with a 2-dimensional array, one index for each week, and another for each day.  Then, you can put the actual string date in each value, or perhaps an array with that day’s events.  Without further ado:

<?php
//CreateMonthView -
//Takes one parameter: a unix timestamp anywhere in the month
function CreateMonthView( $now ) {

    //get numberic day of month (01-31)
    $dayOfMonth = strftime('%d', $now);
    //subtract as approptriate to get to start of month
    $monthStart = $now - (86400 * ($dayOfMonth -1));

    //get numeric day of week (0-6)
    $dayOfWeek = strftime('%w', $monthStart);

    //subtract appropriate number of days to get to the start of the week
    //this will usually be the last part of the previous month
    $calMonthStart = $monthStart - (86400 * $dayOfWeek );

    //initialize variables for while loop
    $thisWeekStart = $calMonthStart;
    $week = 1;
    $monthArray = array();

    //last day of month - text condition for while loop
    $lastDayOfMonth = mktime(23, 59, 59,
                             date("m", $now),
                             date("t", $now),
                             date("Y", $now));

    //foreach week, create a new array to hold the days
    while( $thisWeekStart <= $lastDayOfMonth ) {
        $monthArray[$week] = array();

        //iterate through week - adding each day as a value
        for( $i=0; $i<7; $i++) {
            //get timestamp for each day
            $dayOfWeek = $thisWeekStart + 86400 * $i;
            //convert to a and ISO date - seconds are too precise
            $date = date('Y-m-d',$dayOfWeek);

            //each day will be the value in the array
            $monthArray[$week][] = $date;
        }

        //increment sentinal variable and week counter
        $thisWeekStart = $dayOfWeek + 86400;
        $week++;
    }

    return $monthArray;
}
?>

Now you may be saying to yourself “okay, that’s all fine and good, but it doesn’t do anything on it’s own”, and you’d be right, it’s just a function.  To make something happen, you simply need to call it, and display the result.  Here is another snippet that does just that:

<?php
$month = CreateMonthView( mktime() ); //create the current month

echo '<table>';
foreach( $month as $week ) {
    echo '<tr>';

    foreach ($week as $day ) {
        if( $day == date('Y-m-d') ){
            //apply selector to distinguish today's date
            echo '<td class="today">';
        } else {
            echo '<td>';
        }
        //reduce the complete ISO date down to the day and display it
        echo substr($day, 8, 2);
        echo '</td>';
    }
    echo "</tr>\n";
}
echo '</table>';
?>

Viola! You can certainly copy and paste this code as is, but it’s not very visually exciting. Here’s an example. It could definitely use some styling – but I’ll leave that up to you.

Quick Hash Generator

December 2nd, 2008 by Peter Anselmo No comments »

I often find myself quickly needing the 1-way encrypted value (hash) of a string. Most often, it’s to securely store an individual password into a database or script. Rather than temporarily hard-coding the plain text to see what PHP will generate, I wrote a little reusable script to generate hash values. Anyone who might find it useful can find it here. If you’re paranoid about security, you can find a secure version here, although you may get a warning about my self-signed certificate.

Backing Up is the Cool Thing to Do

November 30th, 2008 by Peter Anselmo 2 comments »
External Backup Drive

External Backup Drive

Backups saved my life yesterday. No, seriously. I upgraded an installation of Drupal, and forgot to copy the files for my Email client before I wrote over the root directory. After trying to check my mail (and getting an empty folder), I had about 30 seconds of complete terror, before I realized I had implemented an automated daily backup system about two months ago. Whew! I found a recent version in my backup files, and bingo, there were my mail client files. So, I’d like to talk a bit about backing up.

Every single person who uses a computer should create an automated backup system. Period. And let me give you a few guidelines: Burning CDs doesn’t cut it. Burning DVDs doesn’t cut it. Both take way too much time and energy, and you will quickly forget to keep up. You need to buy a spare hard drive, and dedicate it to backups. Hard drives are cheap. You can find some excellent options here.

Next, create a system to AUTOMATE the process. You don’t want to have to remember. If you have OSX 10.5, that means setting up Time Machine. I commend Apple on their push for automatic user backups. If you’re using XP, look here. If you’re using Vista, look here. If you’re using Linux. Look here and here.

The last link above is what I use to backup my server, although I use a slightly modified version. I have it set up to backup all my files every night. I keep 6 days of nightly backups at all times. Then, once a week, I do a weekly backup, of which I keep 4 at all times. Finally, on the first of every month, I do a monthly backup, of which I keep the last 12 at all times. The advantages of keeping many versions of your files are two-fold. First, your hard drive may crash slowly. In this case, it will start corrupting files before it outright dies. If you’re only keeping one copy of files on you backup drive, you could end up writing over your good files with corrupted ones. Keeping multiple, redundant versions of your data ensures there will always be healthy versions available. Second, your backup solution now serves as an archive, where you can recover files you may have lost or accidentally deleted (see first paragraph).

After reading this, you have no reason not to have an automated, dedicated backup solution. Please, I urge you, go set one up. The $100-$200 you will spend on an external hard drive is NOTHING compared to the value of your non-replaceable pictures, music, and files.