Posted by Erik on December 8, 2007
Code Here’s a quick one-liner using some UNIX utilities and Perl to construct some nice averages from CSV data: for i in `seq 2 20`; do cat crim_rate_2005_by_state.csv | cut -d , -f $i | perl -e ‘$c=$d=0;$e;while(<>){if(/^\d/){$c+=$_;$d+=1}else{s/\s{2,}/ /g;s/”//g;chomp($e=$_);}} print $e, “: “, $c/$d, “\n”‘; done And now, the spaced out version: #!/bin/bash for i [...]
Posted by Erik on November 25, 2007
So, I have all these JPEGs, and I want to know which ones are corrupt (specifically, ones that end prematurely). qiv will spit out the following to STDERR when it finds one: Premature end of JPEG file So, this is nice, except it’s entirely unscriptable. The solution I found was using the following script to [...]
Posted by Erik on September 18, 2007
Magic EXIF recursive tagging! Have you ever had your files all nicely nested in directories, but needed to change their EXIF dates? Here’s what I used today to do it: # Structure like this: 1997/08/Picture.Whatever Maybe Some Spaces.jpg # Delete the EXIF tags (DONT DO THIS UNLESS YOU KNOW WHAT YOU’RE DOING!) find . -mindepth [...]
Posted by Erik on August 17, 2007
Now, be aware that this could be a security issue if you let strangers onto your IRC session. They could do some cool shell tricks to break out of this exec command into the raw shell itself, but I’ll forget about that for now. I wanted an alias that would allow me to send a [...]
Posted by Erik on July 15, 2007
I use GNU Screen. A lot. I found an article linked from DIgg today that showed me how to use a setting called hardstatus to set the little bar at the bottom to my liking. I decided to mess around with it a bit, and I ended up with this: It shows my hostname, IP, [...]
Posted by Erik on April 16, 2007
DevastatorIIC happened to link me to this today, which I found to be extremely helpful. It’s a collection of small perl scripts that make doing very complicated things very easy. My personal favorite is vipe, which lets you edit a pipeline with vi in the middle of its execution. Another is vidir, which lets you [...]
Posted by Erik on January 21, 2007
So, I am currently hosting this blog on Site5’s $5 Deal. I paid $120 for 2 years of hosting with 55GB HD Space and 5TB/month transfer allowance. So far, I am very happy with it, and I’m going to share some gory details with you. The deal on the site looked to good to be [...]
Posted by Erik on November 5, 2006
I wrote a script today that does a POST to a currently logged in GrandCentral user’s account using Firefox or Mozilla cookies. It’s quite simple really: #!/usr/bin/perl -w # Calls someone using the currently logged in account on GrandCentral.com # User must log in to create the cookie in FireFox or Mozilla # Then, the [...]
Posted by Erik on October 7, 2006
PhishTank is an awesome website that keeps a database of phishing websites that are user submitted and verified. It integrates with OpenDNS, so when a site is verified by the community as a phishing site, OpenDNS users will see a phishing warning instead of the original website. There are also other perks like spelling correction [...]
Posted by Erik on August 14, 2006
Horray! I can evaluate the right side of a regular expression! e Evaluate the right side as an expression. Wow.