Tag Archives: perl

Calculating Averages from a CSV with Perl

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 [...]

Finding bad JPEGs with Xorg hacks in Ubuntu

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 [...]

Setting EXIF dates with a loop

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 [...]

Irssi Alias Magic using Perl

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 [...]

GNU Screen’s hardstatus

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, [...]

Awesome Linux Utilities

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 [...]

Ultimate Hosting Review: Site5

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 [...]

Calling people with GrandCentral and Perl

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 [...]

PhishTank pwns Phishing Phools

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 [...]

Evaluating an expression in a RegExp

Horray! I can evaluate the right side of a regular expression! e Evaluate the right side as an expression. Wow.