Perl -p is the sweetness

A handy trick for programming perl is the -p flag. This tells perl to surround your code with:

while (<>) {
     ...          # your script goes here
} continue {
     print or die "-p destination: $!\n";
}

If you have a file with state names and 2 character codes, like “DE:Delaware”, you could convert that into SQL insert statements by feeding it to a simple perl script like follows:

#!/usr/bin/perl -p -w
s/(.*):(.*)/INSERT INTO states (state_value,state_name) VALUES ('$1','$2');/

Related Posts:

Posted in Programming | Tagged , , , , | 3 Comments

Recursive Descent Parsing

Early in the development of computers, programming languages were simple, and were converted into a machine usable form using a parse tree. Let me give you a little context.

Continue reading

Related Posts:

Posted in Computing History, Humour, Programming | Tagged , , , | 2 Comments

“Microsoft Small BASIC” is not actually bad

I recently started looking at Microsoft Small Basic. I realize that folks who have known me for a long time will be shocked and horrified that I would consider a Microsoft product, since I probably should be trying to teach kids to program with Linux and Python. The reality is that Windows is currently the majority platform, and that a Windows environment makes sense for learning as a result. Happily, the knowledge learned is completely transferable. In any case, Small Basic is a structured BASIC that has turtle graphics and supports things like recursion. I’ll know more later, but for the moment, it seems pretty decent.

Related Posts:

Posted in Programming | Tagged , , , , | 5 Comments

YouTube just Rick Roll’d me!

I signed up for the HTML5 trial, and was impressed when I started seeing videos showing up with WEBM and HTML5 in the controls. Imagine my horror when I discovered that the new “Save as…” feature redirects to “Never Gonna Give You Up!” Kudos, YouTube.

Apparently, this is happening to everyone and is a typical YouTube prank.

Related Posts:

  • No Related Posts
Posted in Bamgoogled | Tagged , , , , | 2 Comments

CPU as GPU

Phoronix has done an interesting thing, they have used the LLVMpipe driver to run a bunch of OpenGL code on a recent Gulftown GPU. Check it out, here.

Related Posts:

Posted in Programming | Tagged , , , | 1 Comment

CodeIgniter: Scalar Variable Attachments

Many systems that provide email sending seem to only allow file attachments. There never seems to be a feature for creating the attachment in a variable and sending it. CodeIgniter, no matter how awesome, is no exception. So, I’ve been forced to cobble together an extension to the email handler which does it. It suffers from being a bit memory piggy, because it caches the attachments in memory so it can treat both file and scalar attachments the same. Take a gander, if you need such a beast.

Continue reading

Related Posts:

Posted in Programming | Tagged , , , , , | Comments Off

Underwood Zork

I learned to type on an IBM Selectric, but many other folks learned to type on a trusty manual typewriter. My folks had one when I was a kid, and I never failed to jam all the keys and leave a fallen-trees after a flood logjam up against the platen.

Other folks have elevated the typewriter to a holy shrine of the text adventure. Check out this link to be impressed.

Related Posts:

  • No Related Posts
Posted in The Hardest Hardware | Tagged , , | 4 Comments

Git In Here!

If you are still using subversion, quit it. Seriously. It is like trying to do version control in handcuffs and without fingers. In my hobby coding, git has saved my butt so many times I can barely count it. I branch and branch and branch with abandon, and can trace the entire thing with no serious effort. The notion of “staging” changes versus just doing huge blocks of change also delights me. Please, check out this article to get you started. Writers, designers, and anyone who works with files at all, should take heed.

Related Posts:

Posted in Metablogging, Programming | Tagged , , | 2 Comments

keine 2 Liter Wasser

I’ve always suspected, but not really bothered to get confirmation, that you didn’t need to drink the glasses and glasses of water that some folks recommend. In fact, there is a lot of evidence that links the bottled water companies with folks saying that you need to guzzle it. The food you eat contains a considerable amount of water, and coffee, tea, soda, and just about any other water-containing liquid counts.

If you don’t mind nearly limitless foul language, Penn & Teller effortlessly debunk a lot of the bottled-water nonsense.

Related Posts:

  • No Related Posts
Posted in Biogeekery | Tagged , , | 3 Comments

Get With The Program DirecTV!

I have been a DirecTV user for years, particularly back when they had DirecTivo units. Those rocked! When they dropped Tivo, I moved to Comcast, since they were supposed to be bringing out Tivo units. Then DirecTV announced they were going to be bringing out Tivo units, so I went back.

Now, apparently, they won’t be released until sometime in 2011. Previously it was 2009, then 2010. C’mon, DirecTV, get with the program!

Related Posts:

Posted in Final Thought | Tagged , , | 2 Comments