Social Network Analysis of Disclosure

Count number of lines in a file

find . -type f -exec cat {} ; | wc -l

and if you don’t want repeats

find . -type f -exec cat {} ; | egrep \S | wc -l

I even thought about cat, but I ended up doing something like:

for i in $( find -H . -type f ); do
  temp=$( wc -l "$i" | cut -f 1 -d  )
  if [ $temp > 0 ]; then
  echo $total
echo $total

Bash Error Checking

I was reading an oriley bash scripting book, and they had an entire chapter dedicated to error checking in bash.  For me, this was a little weird since I think the way they handled it made the code cluttered.

They have cascaded statements like

if [ $ -ne 0 ]; then
#handle error

For me, this is strange.  I think in a bourne shell, the best way is to just set the -e flag, which according to the man page

-e errexit If not interactive, exit immediately if any untested command fails. The exit status of a command is considered to be explicitly tested if the command is used to control an if, elif, while, or until; or if the command is the left hand operand of an “&&” or “||” operator.

This can be accomblished by

set -e

in your script.

Error handling is a balancing act between doing too much and handling everything (thus making the code unreadable) and not checking enough.  Normally, if I need much more error checking than that, time to pull out the python.

convert flash to mp3

Using ffmpeg, anything’s possible

Just install ffmpeg, lame, and then you can do something like

ffmpeg -i flashvid.flv -ar 44100 -ab 160 -ac 2 outfile.mp3


It’s easier than you might think.

socks is actually built into openSSH, so its really a trivial matter to setup a local proxy.

$ ssh -D 12345 myuser@remote_ssh_server

will open up the port 12345 on localhost as a socks proxy and all your traffic can be specified to go through the tunnel and out of remote_ssh_server

For firefox 3, go to Edit->Prefrences->Advanced->Network->Settings

and set it to use a Manual Proxy, localhost, port 12345 socksv5

2.0.38 /usr/src/linus/fs/ufs/ufs_super.c

Linux has definitely lost its cool.

printk(“ufs_read_super: fucking Sun blows men”);

isbn-10 validity identifier

Here’s a program that does the isbn error checking.

#!/usr/bin/env python

#this program checks if isbn-10 numbers are valid

import sys

def usage():
  "You're using it wrong!"

  isbn = sys.argv[1].replace('-','')

isbnNum = isbn[0:9]
checksumPassed = int(isbn[9:])

sum = 0
index = 10
for i in isbnNum:
  sum += int(i)* index
  index -= 1
print "sum is ", sum
checksum = 11 - (sum % 11)

print 11 - checksum
if checksum == checksumPassed:
  print "isbn checksum is fine"
  print "isbn checksum error"