A blog, of sorts, intended as a place to experiment, struggle, question, and play with whatever research I am currently working on. The themes will thus change over time as my projects change, and the entries may be quotations that strike my fancy, attempts to puzzle through hairy problems, notes on sources, experiments, musings, dead ends, odd angles of looking at things. It is a voice to my frustrations, discoveries, curiosities, and confusions. It is thinking out loud. ...More 
code, linux, scraping —
9 Jun 2010
Another boring code snippet for me to remember. How to get lynx references back into hyperlinked format.
lynx -dump URL > filename.txt
for i in $(egrep ^" *[0-9]*\." filename.txt | sed -e 's/^ *//g' | cut -f1 -d ".");
do egrep ^" *\[*$i(\.|\])" filename.txt | tac | perl -p -i -e 's/\n//g' | perl -p -i -e 's/ [0-9]*\. /\n<a href="/g' | tr -s " " | perl -p -i -e 's/ \[[0-9]*\]/">/g' | sed '/^ *$/d' | sed -e 's/$/<\/a><br \/>\n/g' >> filename-clean.html;
done
Comments (0)
linux —
19 Jan 2010
I always forget how to do this, so, by god, I'm going to actually write it down this time so that I don't have to search all over the place next time.
To find a string of text and replace it with part of the original string intact:
sed -i 's/\(foo\)\([A-Z, -]*\)/\1\L\2/g' file.txt
Putting things in escaped parentheses creates a group—\(foo\) is group one, \([A-Z]*\) is group two. Then in the replace string, you call up a group by putting \#. So group 1 becomes \1. Thus, the above replacement string—\1\L\2—means keep group one as is but convert group two, whatever it might be, to lowercase.
Comments (0)
bash, linux, scripts —
4 Jan 2008
I'm a terrible programmer, mainly because I only try to do it when I really need something, instead of just sequestering myself in a room with cheesy puffs and Dr. Pepper for 2 weeks to just do it already. So I find myself having to keep notes when I do anything successfully lest I forget when I need to program again 6 months later. Even the really, really simple shit. Sigh.
Changing file names quickly in a Linux directory with a billion files:
for i in $(ls -1 s_*.gif);
do (( n++ )); mv $i file$n.gif ;
done
Comments (0)