!phil

In my Internet experiences there have been few people that I have met on the Internet and continue to communicate with regularly. Of that select group one stands out. He goes by the alias of !phil. I had to look up a word to describe him and eventually found it:

fulgurant – amazingly impressive brilliance or skill

That would be the word to describe !phil. He seems to be good at whatever he does and that is something I admire. He is a fellow Web Developer and programmer, dare I say a hacker, with a strong personality and vast knowledge.

In my pursuit to build my first web pages he would break them and show me how to fix them. Any question I could throw his way he could answer and educate. His experience with programming, linux, and general curiosity have allowed him to accumulate a wealth of knowledge on all aspects of computers and technology. He was willing to help me despite his own schedule and surely busy life.

!phil has a gift with humor. He can make simple things funny, as evident from the articles on his website, quakephil. One of my daily reads that have made it to my blogroll.

However I did not meet !phil though forums, but rather through games. I played (and occasionally revisit) the ever famous Quakeworld (QW). It is in that arena that the name BogoJoker was born and also where I met !phil. He is a world famous QW player and supporter. He continues to support and represent the QW community in tournaments, websites, and development.

In the words of an old 06′ chat:

me: I should quote that in my blog
      maybe i will ;P.
      i’ll put u under “family” category. hehe

phil: if you want to confuse all 3 of your readers :)

So true… So true… ;)

Code Golf

Programmers are notorious for solving puzzles and games. Essentially code golfing was born from that mind set. The goal of golfing is to get the lowest score. Code golfing as defined from the Code Golf home is:

Based on the original perl golf, Code Golf allows you to show off your code-fu by trying to solve coding problems using the least number of keystrokes.

Essentially the goal is to make your program as small as possible. The fewest bytes, the fewest characters, the smallest it can be. I am rather new to the sport but from what I have gathered it really kicking into action when scripting languages like Perl became popular. The original golf was Perl golf, as mentioned in the quote. Perl is a really cool programming language. Its powerful and robust but most importantly its fun to program. Its syntax is simple and its special variables and dynamic typing make it a joy to use. Interested in learning? However, recently languages like Ruby, PHP, and Python have shown they are just as effective.

How about an example? Lets start with something really basic. Lets add all of the numbers from 1 to N, where N is the number the user provides on the command line. A traditional approach might look like:

#!/usr/bin/perl
use warnings;
use strict; 

my $N = $ARGV[0];  # The given upper limit
my $sum = 0;       # To hold the summation

# Perform the summation
for ($i = 1; $i < $N; $i++) {
  $sum += $i;
}

# Print the result
print $sum, "\n";

Here was my Perl solution weighing in at 28 bytes complete with the terminating newline:

map$i+=$_,1..pop;print$i,$/

Example output:

$ perl sumToN.pl 15
120

It is completely possible that there might even be a smaller solution using a different approach, but you can see what is happening. The code is massively condensed to the point where there is nothing extraneous, nothing but pure code.

For those of you who are wondering why would anyone ever want to do this... you are forgetting that this is merely a game. Its a challenge, a puzzle to occupy your time and entertain your brain. As with all games you get better with practice, you learn new tactics and tricks, my original solution weighed in at 29 bytes using a for loop until I experimented with the map function to cut two characters. Golfing tests your knowledge of the language and helps you learn the secrets at the same time. When is a space or a semicolon necessary? Do I need to create an extra variable? It may not look like it from above, but you will become a better programmer.

More challenges include:

  1. Converting Roman Decimals to Decimal Numbers
  2. Drawing an Egg Timer of size N (Very Cool)
  3. Prime factorizing numbers

The list of games are endless, and the solutions equally immense. So what are you waiting for, take a swing at this challenge inspired by Worse Than Failure (the DailyWTF). Generate a random password of N length of alphanumeric characters (lowercase, uppercase, and numbers). Simply state your language of choice. Remember that the input length N, is provided on the command line as if you were to run the command from your terminal. My solutions weighed in at 59 bytes but I have a very cool 61 byte solution. Here is some example usage for you to work off of:

$ perl genpassword.pl 35
Pm0vfue12fWB45Ctr4Zc2zXNt5wkREGHQan

Pete is Back

Pete returned from Djibouti Africa on Saturday March 17, 2007. He is a member of the Marines and was stationed in Djibouti for the past 6 months. Everyone is glad that he is safe and back in the states.

Give Perl a Chance

I had always wanted to learn Perl. I had a few brief encounters with it, using my php knowledge to drive my Perl programming in a very php styled way. However, I knew Perl could do so much more. I had nearly one week free and decided to give Perl a serious chance. I happened upon a great book available free from perl.org and was more than pleased.

Beginning Perl is available in PDF form for free from the Perl website. The book gives a very high quality, engaging, and through description of Perl. If you have been interested in learning Perl give this book a go and I assure you that you will get hooked into how the author daftly portrays subjects and concepts with excellent concise code examples and explanations. This is the kind of programming book that every programmer searches for. It is so engaging you will find that you will go through a chapter a day. The author has a gift for breaking subjects down to simple concepts, which is after all the real core of programming.

Make sure that you print out the appendixes. Read them over if you really want to grasp the full power of Perl and its endless options, special variables, and famous regular expressions. The actual chapter on regular expressions even tipped me off to certain tricks that I was even unaware of (lookaheads and lookbehinds). However if you are looking for a more general explanation of regular expressions I still recommend the links that I posted at the bottom of this article.

Many have considered Perl to be a confusing language. The book’s introduction declares that it means to dispel that rumor. Here is the direct quote from the introduction, hopefully it will motivate some of you to grab the PDFs and take a look:

However, since Perl is so easy to learn and to use, especially for quick little administrative tasks, ‘real’ Perl users tend to write programs for small, specific jobs. In these cases, the code is meant to have a short lifespan and is for the programmer’s eyes only. The problem is, these programs may live a little longer than the programmer expects and be seen by other eyes too. The result is a cryptic one-liner that is incomprehensible to everyone but the original programmer. Because of the proliferation of these rather concise and confusing programs, Perl has developed a reputation for being arcane and unintelligible – one that I hope we can dispel during the course of this book.

I will admit that the book is flawless in its persistence of providing full quality Perl scripts. I always strive to optimize my code, normally trying to increase efficiency and readability in my algorithms. However, Perl’s incredible flexibility does allow programmers to do some rather unbelievable tasks in well under 100 bytes (1 byte = 1 character). I will soon write an article about the dark side of every programmer… code golfing.

Paetec Co-op

This last week has been intense. I was entertained by 3 finals during finals week at RIT (Rochester Institute of Technology). However, a few days after my last final I started my first full time co-op position as a software developer at Paetec.

Paetec has been in the news recently for going public and merging with another Telecommunications company, US LEC. A description of the recent excitement can be found here. I will admit that I am very excited to start a real programming job and am honored to be working at Paetec.

The employees have all been accepting and helpful. I have already started writing some real code and digging into the system. I look forward to the next few weeks, right now I am really soaking it all in and learning everything I can. I am already getting more and more comfortable at the company.

I welcome reader comments on their co-op experiences. Where/How were your first co-ops or full time jobs? What were some of the ups and downs or highlights of the position?

My Desktops

I have always enjoyed customizing my desktop since the original wallpapers in Windows 98 and onward were so bland. I hope you enjoy this Widget view of the past year’s themes which involved WindowBlinds, CursorXP, and some deviant art browsing for wallpapers.

If you have any questions about any of the settings you see above feel free to ask me. I have close to a hundred vector wallpapers that will forever remain in my picture folder! Got a picture of your desktop? Drop me a link.

search