New Site Design

September 23rd, 2006

I’ve updated the look of my site. I think it’s a bit more modern. I also got a bit fancy with my background image. I’m obsessed with randomness, so i wanted to make sure I could have a random background image. That part is easy.

< ?
include_once('bggenerator.php');
$bg_file = background_name($_COOKIE['width'],$_COOKIE['height']);
?>
body { background: url(”< ? print $bg_file; ?>“) fixed; }

What’s up with the cookie height and width you say? At first load, i use Javascript to grab the size of each visitors viewing window and store it in a cookie. I then refresh the page. The cookie values are passed to my background generation function which: picks a random image, and resizes it to your specific size. The filepath in the below example is just for show, it gets more specific, especially if you are using WordPress. For the “showExtension” function, go to Google and enter “php showExtension”. It’s located on that first page somewhere.


function background_name($width, $height)
{
$dir = 'bg';
$files = scandir($dir);
$valid_extensions = array('jpg', 'gif', 'png', 'bmp');
foreach ($files as $filename)
{
$filepath = $dir.'/'.$filename;
$tmp_ext = showExtension($filepath);
if(in_array($tmp_ext,$valid_extensions))
{
$backgrounds[] = $filepath;
}
}
$rand_key = array_rand($backgrounds);
$filename = $backgrounds[$rand_key];
list($name, $ext) = explode('.',$filename);
$ext = strtoupper($ext);
$bg_file = "$name.$height-$width.$ext";
if(file_exists("$bg_file"))
{
return $bg_file;
}
else
{
createbg("$filename","$bg_file",$width,$height);
}
return $bg_file;
}

My createbg function takes an image name, a desired new name, and the size to change the image to.

/*
Function createthumb($name,$filename,$new_w,$new_h)
creates a resized image
variables:
$name Original filename
$filename Filename of the resized image
$new_w width of resized image
$new_h height of resized image
*/
function createbg($name,$filename,$new_w,$new_h)
{
$system=explode(".",$name);
if (preg_match("/jpg|jpeg/",$system[1])){$src_img=imagecreatefromjpeg($name);}
if (preg_match("/png/",$system[1])){$src_img=imagecreatefrompng($name);}
$old_x=imageSX($src_img);
$old_y=imageSY($src_img);
$dst_img=ImageCreateTrueColor($new_w,$new_h);
imagecopyresampled($dst_img,$src_img,0,0,0,0,$new_w,$new_h,$old_x,$old_y);
if (preg_match("/png/",$system[1]))
{
imagepng($dst_img,$filename);
}
else
{
imagejpeg($dst_img,$filename);
}
imagedestroy($dst_img);
imagedestroy($src_img);
}

And there you have it. Random backgrounds that are resized to your visitors window sizes. This is probably going to take up a lot of space in my directories, so if space is important for you, you might want to just use the random part.

ENFP?

September 22nd, 2006

I took a personality test tonight. Turns out I am an ENFP or Extraverted iNtuitive Feeling Perceiving kind of guy. One description said I was a “Champion Idealist.” I like the way that sounds. These tests are frightenly accurate. Here’s a summary:

The following comes partially from the archetype, but mostly from my own dealings with ENFPs.]

General: ENFPs are both “idea”-people and “people”-people, who see everyone and everything as part of an often bizarre cosmic whole. They want to both help (at least, their own definition of “help”) and be liked and admired by other people, on bo th an individual and a humanitarian level. They are interested in new ideas on principle, but ultimately discard most of them for one reason or another.

Social/Personal Relationships: ENFPs have a great deal of zany charm, which can ingratiate them to the more stodgy types in spite of their unconventionality. They are outgoing, fun, and genuinely like people. As SOs/mates they are warm, affectionate (l ots of PDA), and disconcertingly spontaneous. However, attention span in relationships can be short; ENFPs are easily intrigued and distracted by new friends and acquaintances, forgetting about the older ones for long stretches at a time. Less mature ENFPs may need to feel they are the center of attention all the time, to reassure them that everyone thinks they’re a wonderful and fascinating person.

ENFPs often have strong, if unconvential, convictions on various issues related to their Cosmic View. They usually try to use their social skills and contacts to persuade people gently of the rightness of these views; his sometimes results in their negle cting their nearest and dearest while flitting around trying to save the world.
Work Environment: ENFPs are pleasant, easygoing, and usually fun to work with. They come up with great ideas, and are a major asset in brainstorming sessions. Followthrough tends to be a problem, however; they tend to get bored quickly, especially if a newer, more interesting project comes along. They also tend to be procrastinators, both about meeting hard deadlines and about performing any small, uninteresting tasks that they’ve been assigned. ENFPs are at their most useful when working in a group w ith a J or two to take up the slack.

ENFPs hate bureaucracy, both in principle and in practice; they will always make a point of launching one of their crusades against some aspect of it.

Another one:

ENFPs are friendly folks. Most are really enjoyable people. Some of the most soft-hearted people are ENFPs.

ENFPs have what some call a “silly switch.” They can be intellectual, serious, all business for a while, but whenever they get the chance, they flip that switch and become CAPTAIN WILDCHILD, the scourge of the swimming pool, ticklers par excellence. Som etimes they may even appear intoxicated when the “switch” is flipped.

One study has shown that ENFPs are significantly overrepresented in psychodrama. Most have a natural propensity for role-playing and acting.

ENFPs like to tell funny stories, especially about their friends. This penchant may be why many are attracted to journalism. I kid one of my ENFP friends that if I want the sixth fleet to know something, I’ll just tell him.

ENFPs are global learners. Close enough is satisfactory to the ENFP, which may unnerve more precise thinking types, especially with such things as piano practice (”three quarter notes or four … what’s the difference?”) Amazingly, some ENFPs are adept at exacting disciplines such as mathematics.

Friends are what life is about to ENFPs, moreso even than the other NFs. They hold up their end of the relationship, sometimes being victimized by less caring individuals. ENFPs are energized by being around people. Some have real difficulty being alone , especially on a regular basis.

One ENFP colleague, a social worker, had such tremendous interpersonal skills that she put her interviewers at ease during her own job interview. She had the ability to make strangers feel like old friends.

ENFPs sometimes can be blindsided by their secondary Feeling function. Hasty decisions based on deeply felt values may boil over with unpredictable results. More than one ENFP has abruptly quit a job in such a moment.

You can read more about these types at http://typelogic.com/enfp.html.

You can take the test for yourself at Human Metrics.

WebJukebox

August 25th, 2006

I just installed WebJukebox from CoffeeCup software. It’s great .

AJAX is awesome

August 18th, 2006

I’d like to publicly state that I love AJAX. I have discovered it, and i’m never going back.

As a new programmer, I was confined to command-line scripts and printing to file. NO LONGER! With web pages I can create something completely accessible. With AJAX and my 2 favorite libraries Prototype and it’s sexy little sister Scriptaculous I can create pages that are friggin cool. I’m currently working on new order pages for Lunarpages. Wait until I’m done. You will be impressed.

EDIT
Moo.fx is nice too.