Archive for March, 2009

useful scripts for digging through code

Monday, March 30th, 2009

After a little bit of digging on my now seldom used desktop machine I found some useful scripts I’d share with you all. They’re real good if you’re in the CLI a lot trying to make sense of large amounts of code.

Amongst others, a ~/.bashrc file to rule them all.

The bash goodness:

g foo: what lines of what files contain the word foo?
cat somefile | gi foo

.... : cd ../../..

f foo: case-insensitive search for file foo.

finn foo: find filenames containing ‘foo’. Sensitive but won’t print svn garbage.

p foo: highlight processes matching ‘foo’

fsym foo: search for symbol foo in all objects in subfolders.

rsym foo: check if links properly

Persistent vim windows.

Further: gvimws allows you to always open new files in the same editor on the current desktop. It also closes the file in any other editor on any other desktop automatically.

And the kicker: ve will allow you to quickly open the files you’ve been searching for (using gvimws)

Putting it together

kwy@amaeth ~$ dmesg | gi error
1404:[27214.044072] iwlagn: Error sending REPLY_ADD_STA: time out after 500ms.
kwy@amaeth ~$ cd /usr/src/linux
kwy@amaeth /usr/src/linux$ f iwl-core
# doubleclick-select midclick-paste the above line.
kwy@amaeth /usr/src/linux$ cdd  ./drivers/net/wireless/iwlwifi/iwl-core.c
kwy@amaeth  /usr/src/linux/drivers/net/wireless/iwlwifi$ g time out
iwl3945-base.c:767:			IWL_ERROR("Error sending %s: time out after %dms.n",
iwl3945-base.c:1590:			IWL_ERROR("Time out reading EEPROM[%d]", addr);
iwl-eeprom.c:246:			IWL_ERROR("Time out reading EEPROM[%d]", addr);
iwl-hcmd.c:186:			IWL_ERROR("Error sending %s: time out after %dms.n",
#select-paste filename:lineno pair from above
kwy@amaeth  /usr/src/linux/drivers/net/wireless/iwlwifi$ ve iwl-hcmd.c:186:
# BAM you have found the problem

The fsym and rsym functions are the kind of thing that you’ll never need unless you’re maintaining a large build with libraries that often break. fsym will find the object file that contains the symbol you’re looking for. rsym will do more than ldd and the compiler do to check if your lib is linking correctly.

The all singing, all dancing vimrc file

It’s swell. Switch buffers with F3/F4, do typeahead search and all kinds of crazy things you’ll never find out about until you happen to press the wrong button. Just like all of vim.

cross-reference like CSI

Friday, March 27th, 2009

I was watching The Mentalist the other night and during the course of a murder investigation they ask the cute geeky cop to “cross-reference” the list of people with brown cars with the list of buyers of a specific toothpaste brand.

She brings up a fancy display of two lists and punches the keyboard a few times, and suddenly a couple of entries in the list are highlighted – the murder suspects. So without further ado I bring you this ultimate crime-fighting tool:

(link updated)
Usage: Download; mv bin/crossref; chmod +x bin/crossref; crossref list1 list2

If you’re on windows you’ll need ActivePerl or Strawberry Perl.

It may not have any fancy graphics, but it’ll get the job done and hey – this isn’t a TV series.

politiet sliter

Tuesday, March 17th, 2009

Politiet sliter med datasystemene sine. En kollega har allerede nevnt saken. Det er skremmende men slett ikke overraskende. Det tar nok mer enn to uker før de får kontroll på viruset, spør du meg.

Jeg lurer på om vi på Redpill-Linpro ikke kunne hjulpet dem litt.
Gode forslag flyr rundt på kontoret:

Vi kunne brannvegget de så viruset ikke sprer seg. Vi kunne satt dem opp med tynnklienter og MultiFrame. Vi kunne fått orden på deres skrivbare shares med litt samba-magi. Vi kunne fått deres applikasjoner over på wine, eller virtualisert dem. Vi kunne stuntmigrert dem ved hjelp av noen usbnøkler og/eller litt PXE-foo – og så, ikke mere virus.

En ting er bra sikkert: det kommer til å ta dem ukesvis bare å få kontroll hvis de fortsetter med det nåværende systemet.. og de utsetter seg for at noe lignende skjer igjen og igjen og igjen.

Bonusen er at våre løsninger er åpen kildekode, så klart!

the important bits

Monday, March 16th, 2009

instead of giving you another machine-breaking tip I’ll just point you to where you’ll find writ a collection for your reading pleasure…

how to break your debian: mix and match packages

Friday, March 6th, 2009

Let us say that you are, like me, a debian (or ubuntu) user with special needs. You have a kick-ass new laptop and you need the latest linux kernel to get all the fancy gadgets working – like your ethernet adapter.

Your computer is your work environment, so you gave up on sid / jaunty because spending a couple hours a week figuring out why apt is barfing is not an option when clients are breathing down your neck. Also, when update-manager tells you “There are 277 updates” every other day you’ll get sick of booting into the New World just to find out that the New World smells kinda funny and has no pizza. Figuratively speaking.

How to get the best of both worlds?