Archive

Archive for the ‘c0de’ Category

Hacking Perl

November 18th, 2008 Christer Edwards 2 comments

As I mentioned in yesterdays post, I have begun studying perl.  I’m actually enjoying it quite a bit, and picking things up fairly quickly I think.  I’m sure my familiarity with bash scripting helps quite a bit.

This morning I hacked together an irssi script for origami users that will let you display your current work unit progress percentage within irssi chat.  I’d like some feedback on it.

If you are using irssi and have origami running on the same machine please check out my plugin and let me know what can be improved.

Download origami.pl v0.2

Instructions:

download and save the above script into ~/.irssi/scripts

To load the script:

/script load origami.pl

To get the origami work unit status:

/origami

To unload the script:

/script unload origami

If this article has been helpful, please consider linking to it.

Categories: c0de Tags: ,

Regex Challenge

November 17th, 2008 Christer Edwards 26 comments

Over the weekend I started studying Perl and quickly realized I was going to be better off if I reviewed regular expressions before I got too far into things.  I went back and found my copy of “Mastering Regular Expressions” and dove right in.  Now, maybe its just me, but I find that I really enjoy the problem solving aspect of regular expressions.  I thought it might be fun to put up a regular challenge on the blog that needs to be solved via regular expressions.

(Obligatory xkcd reference)

So, I figure I’d start off with one that caught me today.  Here is the situation:

You’ve got a regular text file filled with usernames.  You want to be able to read this file into a program to populate an array, but there are random blank lines throughout the file.  What regex would you use to find and remove all empty lines in the file?

For consistency sake, I’ve populated just such a file and made it available here.

Rules: Use any tool you want (perl, sed, vim, etc)  The file must contain all original usernames (total of 15), one per line, with no blank lines start to finish.  Please share your solution in the comments!

Categories: c0de Tags: ,

Project Update Announcements

March 21st, 2008 Christer Edwards No comments

I wanted to quickly toss something out there for all of you on the interweb.  I spent some time last evening cleaning up a few of my code projects.  If you have been using either of them you may want to update.

apturl for Gnome Do

I spent some time in the #gnome-do channel last nite seeing what needed to be done for the apturl plugin to become better supported.  The end result is that its much cleaner, properly licensed and has been submitted to the do-plugins branch on launchpad for possible future inclusion in the “official” plugins package.  If you have been using the apturl plugin for Gnome Do and saw some recent breakage, you can download the new known-to-be-working-on-0.4 version here.

GoogleSecure Greasemonkey Script

I’m a big fanboy of data encryption, including encrypting as much of my web traffic as I can.  I hacked together a small Greasemonkey script long ago that will force encryption on any supported Google application (gmail, reader, docs, calendar, etc), and recently added Twitter as well.  I guess that might be cause for a name change, but I didn’t get that far.  I would like to extend the list of sites that it supports, so if you know of any sites that offer https on login but don’t require (but support) https session-wide, let me know.  If you’re interested in this tool you can download Greasemonkey here and GoogleSecure here.

folding.sh

I also have time set aside today to try and squash two remaining bugs in folding.sh.  For all of you great folks that have been using folding.sh, expect an update fairly soon.

Categories: Folding, GNOME, Security, c0de Tags:

Can You Improve This Command Line Magic?

August 13th, 2007 Christer Edwards 19 comments

Today I needed to come up with some more command line magic. You might remember the post I did about digging out of holes with some command line magic. Today’s goal was to do some math, or more specifically, find an average of numbers based from data in a text file. I asked around in IRC for some solutions and one user (the genius coder) came up with something in about two-minutes. Can you improve this or do it with another language? Bash? Python? C? I’d like to see other implementations if you’d like to take the challenge. It’s not much but gets your mind going…

Here is a link to an example file I’m sourcing from. Not the exact same, but you get the idea. Basically taking quarterly data and averaging it. (Let’s not get into a discussion on a better way to store this data in the first place, I’m just looking at clean ways to average the data.)

First submission here:

cat quarterly.txt | grep Q3 | cut -d “=” -f2 | perl -e ‘$a=0;$b=0;while(<>){$a++;$b+=$_;}print $b/$a.”\n”;’

I’m sure some of you Perl mongers can play some golf with this. Who else wants to try?

Categories: c0de Tags: