Archive for May, 2009

28 May, 2009

Survey of Perl Modules I Can’t Live Without, Part II

by gorthx

Part I covered modules specific to the network management part of my job. These are my favorite general-purpose modules.

1. Viewing data structures:
Data::Dumper::Simple
with:
$Data::Dumper::Indent = 1; #JMO
I learned a lot about references using this module, too.

2. Saving myself from the tyranny of Microsoft:
Spreadsheet::ParseExcel automates what would be a daily, very tedious task. (Don’t ask unless you are willing to buy me a beer in order to hear the story behind this.)

3. Automating version control:
CVS::Simple, which I’m in the process of replacing with Git::Wrapper. I’m learning git at the same time, so it’s quite a wild ride.

4. I’m writing tests, try not to faint:
Test::Most and Test::Mockobject

5. Enforcing coding standards:
Perl::Critic

6. Having fun at my co-workers’ expense:
Lingua::Bork. Pass the daily reports through this, and see who’s actually reading them.

7. And of course, DBI. Don’t leave home without it.

Update on some others I mentioned:

Cisco::Reconfig is still intriguing. I’ve encountered a couple of quirks and am trying to figure out if It’s Just Me ™ or they’re actual bugs.

Last time I worked with Net::MAC was v1.2, and I encountered what I thought might be a bug when iterating over an array of mac addresses. I didn’t need it for any heavy lifting (just converting macs to cisco format), so instead of filing a bug report, I stuck with my hand-rolled solution. The problem has been fixed in 1.5.

Advertisements
Tags:
22 May, 2009

Replicating cvs’s -I option in git.

by gorthx

I’m a fairly recent convert to git, and have been moving a bunch of my coding & doc projects to it. It’s been mostly seamless, but I had one kinda tricky piece left: the daily commit (automated, of course) of any notable changes to my Cisco router & switch configs. The tricky part is handling certain lines in the configs that change each time, but aren’t necessarily of interest (for example, ntp clock-period), and I don’t want to kick off a commit if that’s all that’s changed.

cvs has this nifty -I cli option, similar to the -I option to gnu diff – it allows you to specify a regexp and the cvs diff will ignore all lines that match that regexp.

Here’s a sampling of what I had:
cvs diff
-I 'clock-period'
-I '#time'
-I 'set.spantree.port.*cost'
[filename]

(Note that you can’t have spaces in the regexp you pass to cvs.)

git doesn’t have a cli switch for this; I was having a tough time figuring out how to make it use gnu diff. This gave me the tip I needed.

So, here we go!

0. If you don’t have gnu diff on your machine, install it. (I got mine from sunfreeware.com.) You can just run diff without any args to see the options – if you’re missing “I”, you don’t have the right diff.

1. Set up a wrapper script that uses gnu diff:
:::-->cat /home/gabrielle/bin/ciscodiff.sh
#!/usr/bin/bash
#make git use gnu diff and ignore certain lines
/path/to/gnu/diff
-I 'clock-period'
-I '#time'
-I 'set spantree port.*cost'
$2 $5 | cat

Notes:
– I don’t need the . instead of the space, like I did in the cvs regexp – so this is a more restrictive match. (Which I like.)
– $2 and $5 specify which of the parameters for git diff actually are passed through to this diff. See the “git Diffs” section of the manual.

Make sure to make this executable. :)

2. Then, back in my git repo, I added the following to .git/config:
[diff "ciscoconf"]
command = /home/gabrielle/bin/ciscodiff.sh

3. Then I created .gitattributes, like so:
*-confg diff=ciscoconf

git will now use my special diff wrapper *only* on files with names that match the *-confg glob pattern.

Voila.

Tags:
8 May, 2009

Betcha can’t eat just one.

by gorthx

Talks I’m planning on attending at Open Source Bridge:

Open Source on the Farm – to see where I can help out.

Work for the Government for Fun and Profit – I used to work for the feds & it was definitely fun. Plus, I want to hear what Ms Bryant’s been up to lately.

Drop ACID and think about data – to expand my horizons.

Ask Forgiveness not Permission – Uhm, just in case I need to do this. :cough:

CodeIgniter As Drinking Game – I don’t think I need to state why I’m going to this one. (Seriously though, @christiekoehler gave a talk on this recently, and I am interested in CodeIgnitor.)

Assholes are killing your project – this is actually happening in one of my non-F/LOSS projects. I need some tools to cope, and to help me make a decision.

Faking It Til I Make It: A Woman On The Fringe Of Open Source – I want to hear what @ubergeeke has to say about this.

Open Source Development – The Dark Side – this looks like it’ll be funny. It’s good to be able to laugh at yourself.

Remember Tcl/ Tk? Grandpa might be old, but he can still kick your ass! – I still use Expect, built on Tcl/Tk. It rocks.

Others I recommend:
Is the Web Down? – This will be informative *and* entertaining, guaranteed.

Advanced Git tutorial: Not your average VCS. – I’ve seen this already & it’s awesome. This is what really built a fire under me & got me using git.

Unit Test Your Database! – I just started tinkering with PgTAP; looks like an excellent tool.

Tags:
4 May, 2009

This Week in Geekville: Barcamp!

by gorthx

This was my first Barcamp. I’m sad I couldn’t make it to all of Saturday’s sessions – they looked great!

I only made it to two talks. First, Peter Eschright’s “Rat Salad” talk, which, I admit, I was attracted to by the possibility of gross stories. (I have some, being a former employee of CFSAN myself*.) We had an interesting discussion on what software development industry can learn from food safety initiatives.

Next up, my session on munin. (Which is pronounced “moonin”, like the thing you do on the Barfly bus.) I was hoping to find other users to discuss it, but that seemed to be what everyone came to the session looking for too. Next time I will just do my standard network management intro talk & review of tools. This was too specific for Barcamp, I think.

Igals’ TrainPorn session was next on my list, but I got sucked into Audrey Eschright’s “Creating Awkwardness” on my way through the forum. Lots of discussion about circles of friends vs circles of trust, how to protect your information, and of course some tales from the trenches (my favorite part.)

The beer ran out 30 minutes before my “How to change a flat” session. One should never attempt bike maintenance without beer, but we did anyway. We had a bigger crowd than I expected. Thanks to @robotadam for being a spokesmodel**, and @shawnzyoo for the backup!

I finished up with an intro yo-yo session from @pdxyoyo, and only hit myself in the face once.

It was fun meeting people I’ve only been hearing about. :) Thanks to Cubespace for hosting & providing yummy yummy food.

Coming up next week, apparently I’m participating in the QA talk at PDX.pm. I’ll be the one wearing a red shirt.

* My copy of the “Food Defect Action Levels” publication is a big hit at parties.
** Pun intentional.