Thursday, June 28, 2007

Origins and History of the Hackers, 1961-1995

Origins and History of the Hackers, 1961-1995: "“Given a sufficiently large number of eyeballs, all bugs are shallow”."

I think this also applies to hardware design.

Tuesday, June 26, 2007

Perl Basics: For Loops

for (starting assignment; test condition; increment)
{
code to repeat
}

Example:

for ($count=1; $count<11; $count++)
{
print 'cool\n';
}

Monday, June 25, 2007

Redbeard's Thoughts

Redbeard's Thoughts: "Here's a simple tip for using xargs to replace for loops on the commandline.

The other day I needed to rename a set of files to a set of names that didn't necessarily work well programatically. While there are tools to do this (vidir comes to mind) I didn't have any available. So I created a simple file to math things up:
sourcefile1 destfile-a
sourcefile3 destfile-b
sourcefile2 destfile-c
Then I ran this command:
cat movelist xargs -n 2 mv"

cheatsheet

cheatsheet: "Using awk, uniq, and grep to filter files

For example for a file web.log with entries that look like
216.103.110.18 - - [27/Mar/2002:03:59:14 -0500] 'GET /people/index.htm HTTP/1.1'
304 - 'http://www.plambeck.org.com/index.htm' 'Mozilla/4.0 (compatible; MSIE 6.0; Win
dows 98; Q312461)'

Use the command
cat web.log awk -F- '{print $1}'

to display the first word on each line that comes before the - sign (ie, the IP address in the example above).

Then use some combination of use 'uniq' and 'sort' to achieve your goal; for example
cat web.log awk -F- '{print $1}' sort uniq -c

to print out number of log entries per IP number.

To get grep to print out lines that don't match a pattern, use the -v option:
cat web.log grep -v 216 "

Thursday, June 14, 2007

Slurping Text

perl.com: Perl Slurp-Eaze: "Perl Slurp-Eaze
by Uri Guttman"

Very useful article on slurping text. The implementation at the end of the article allows easy access to a file and its content.