Torture of various coding and scripting languages has always been fun.
And it's not been outlawed yet! Excellent!
Encompasses torture of the languages, torture of the compilers & runtime env.
Torture of people reading the code and running scripts.
Brilliant.
So anyway this "torture" I mention is half in jest BUT if you take a look further it is easy to see it is true. You will be a subject of my torture >;)
Some more recent torture (march 2009) embed rss feeds in web page. Google AJAX and Facebook badge. index-just-plainestgooglefeed.html index-with-blog-rss-feeds.html
notes on coding/scripting
notes on process/quality
torture of PI and FreeMind
Our minds (human beings) are an organised mess of stuff. Often doing _stuff_ also becomes messy, scripting and programming IS messy. .... unless you ignore the error handling that is!!!! :) This has been mentioned before I think. Comes from perl philosophy. Also from XP. Somewhere on the web (! :)) [1] someone mentions how they restarted project from scratch, threw out all the messy code. Were very brave. In the days before XP but when "redesigning" and other re- words were equally applicable buzzwords. I recall thinking of throwing away & redesigning as good around the same time OO and UML were huge. My young and easily impressionable years! :) (see the treadmarks still left)
I like XP. But XP would say be brave and throw it the hell out and refactor. Wouldn't it? Well, not quite, NO in fact. Yes refactor, throw it AWAY if you are have been implementing XP and you have your huge set of regression tests that you will get all to pass after you refactor. This large set of tests gives you great confidence. Allows us to be brave! So ... um, yep, in reality XP programmers are cowardly wusses and all this talk of bravery just makes us feel cool :)
Back to refactor. Without XP. If you have a large interlinked "mess" of code. All talking happily internally and handling everything relatively stably. Without tests. Then throwing away the code which is the distilled essence of all the time the developers have put into developing and testing is more than throwing out code. It is also chucking experience and all the testing & debugging & fixing out too. Even if have tests .... was there a test made for every weird thing ever fixed? AND are they still there? Past refactoring might mean that unit tests put in to check specific situations disappear. So must rely on functional tests as test bed to make us brave.
oMLG! enuf guff! Stop ALREADY!
[2]jwz - nomo zilla
"
[2]
Joel On Software - Things You Should Never Do
-rw-rw-r-- 1 jamesey jamesey 15673 Feb 16 2004 ~.fvwm/.fvwm2rc -rw-rw-r-- 1 jamesey jamesey 4074 Feb 17 2004 ~/.xchat/xchat-hacks.pl -rwxr-xr-x 1 jamesey jamesey 11253 Oct 15 11:35 ~/.xchat/xchat-alert.plThe .fvwm2rc is so changed as to be utterly unrecognisable I think. xchat-hacks.pl has a few lines still recognisable. xchat-alert.pl is actually what I use HAS throttling and doesn't die if people paste weird chars
This seq I figured out/played with before and have had to with similar (but different). This is in particular for Red hat 9 but modified to add fvwm2 support. /usr/X11R6/bin/startx calls /etc/X11/xinit/xinitrc does xmodmap and xkbdmap stuff if user has ~./Xclients execs it (presumably to start wm (where I should've put fvwm2 start code)) calls /etc/X11/xinit/Xclients (or maybe start fvwm if else fails:) e.g. all else fails => FVWM2=/usr/local/bin/fvwm2 if [ -f $FVWM2 ]; then exec $FVWM2 fi exec twm /etc/X11/xinit/Xclients decides what wm to use source /etc/sysconfig/desktop DESKTOP="GNOME" #old DESKTOP="FVWM2" # me and starts gnome or kde and/or windowmaker or fvwm2 redhat did have fvwm* stuff in there ... which didn't work. anyway remember this for future reference. In future look first to making ~/.Xclients Good start: cp /etc/X11/xinit/Xclients ~/.Xclients
Watch a file or directory for change and jump up and down when it does: DirMon.pl No, there isn't a _standard_ better way yet IMHO. Has to go inside a kernel. Would be nice if/when this would become standard.
getwotd dial up the oed.com and haul down wotd and email; it to yourself every day.
sfa Scriptie to support multiple users for Slime Forest Adventure. Installs multi-user support if not there already. Wants to do sudo.
viewTimesheet.pl Browse timesheet file (with unix timestamps start every line end with :
reportGiftTrans.php Perl connect to mySQL, slurp out stuff, organise it & print report.
MopsCrypt.pm MopsCryptTest.pl Interface to GnuPG and tests for this module.
greek.csv =&nbgt; iso88597csv2hypercom.pl
=&nbgt; greek2greeklish.pl
=&nbgt; (+ source code) convert.pl
rfc2616
- Hypertext Transfer Protocol -- HTTP/1.1
Apply translations to source code.
Translate translation csv files between iso8859-7 and proprietary hypercom format.
http auth manually
wget -O report.html --http-user="$user" --http-passwd=$password http://server/path/script
in /etc/wgetrc
http_proxy = http://proxy:8080/
ftp_proxy = http://proxy:8080/
rfc2068
- Hypertext Transfer Protocol -- HTTP/1.1
rfc2069
- An Extension to HTTP : Digest Access Authentication
$ grep "03/Feb/2004" /var/log/httpd/access_log |head -n 20
192.168.10.1 - - [03/Feb/2004:09:34:49 +0000] "GET /thing/script.php HTTP/1.0" 200 5239 "http://server/thing/" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030624 Netscape/7.1"
$ telnet localhost 80
GET /thing/script.php HTTP/1.0" 200 0 "http://server/thing/" "Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:1.2.1) Gecko/20030225
response:
HTTP/1.1 401 Authorization Required
WWW-Authenticate: Basic realm="multi"
so ask user for username & password for "multi"
$ perl -e 'use MIME::Base64;$encoded = encode_base64("username:password");print $encoded;'
telnet bakunin.dev.ie.alphyra.com 80
GET /thing/script.php HTTP/1.0" 200 0 "http://server/thing/" "Mozilla/5.0 (X11; U; Linux i686; ja-JP; rv:1.2.1) Gecko/20030225
Authorization: Basic c3RlbGxhOnN0ZWxsYQ==
password hashing, /etc/passwd and /etc/shadow
#!/usr/bin/perl -w
use strict;
use Test::Simple tests => 4;
sub test_passhash() {
my $password = "a vrry seekret passwd";
my $hash = password_hash($password);
print "Password hash is $hash\n";
ok($hash =~ "\\\$1\\\$........\\\$......................\$", "password hashed");
my $ret = password_verify($password, $hash);
ok($ret, "password hash verified");
my $retbad1 = password_verify("wrong password", $hash);
my $retbad2 = password_verify($password, "wrong hash");
ok(!$retbad1, "incorrect password verify fails");
ok(!$retbad2, "incorrect password hash verify fails");
}
sub password_verify {
#password passed in or a default for testing & hexperimentation
my ( $this, $password, $phash ) = @_;
# get password hash from somewhere
my $res = crypt($password,$phash);
return($res eq $phash);
}
# make password hash that can be stored
sub password_hash {
# password passed in or a default for testing & hexperimentation
my ( $this, $password ) = @_;
# generate salt (for MD5 this is, conforming to what passwd does)
# this is currently how my redhat 9.1 linux shadow passwd system generates password hashes
# $1$ then 8 random chars (from [./0-9a-zA-Z]) then $
# of course we could generate our own style salt
# e.g. $salt = "\$1\$abcdefgh\$"; $salt = "\$1\$abc\$"; $salt = "Ga";
my $salt = "\$1\$";
$salt .= join("", (".", "/", 0..9, "A".."Z", "a".."z")
[rand 64, rand 64, rand 64, rand 64, rand 64, rand 64, rand 64, rand 64]);
# or 3 char md5
#$salt .= join("", (".", "/", 0..9, A..Z, a..z)[rand 64, rand 64, rand 64]);
$salt .= "\$";
# or 2 char des (not md5 (no \$1\$))
#$salt = join("", (".", "/", 0..9, A..Z, a..z)[rand 64, rand 64]);
my $phash = crypt($password,$salt);
print "salt $salt passwd $passwd\nhash $phash\n";
return $phash;
}
gpg GnuPG
Read
The GNU Privacy Handbook.
GnuPG is a
RFC2440 (OpenPGP) compliant application.
here are my keys: keys
e.g. perl modules
GnuPG::Interface
GnuPG
Crypt::*lots*
also interesting and useful is gpg-dialog.pl
Jagadeesh Venugopal gpg-dialog@jagadeesh.org
recommend to help with key management & other gpg work by hand
mutt
--command-fd interface to gpg, using expect OR perl
From MopsCrupt.pm _yet_ another interface to gpg.
Fun to write & test this. :)
use IPC::Open3; sub _expect_gpg($%) { my $self = shift; my %args = @_; my %rethash; $self->{error} = ""; # e.g. spawn gpg --with-colons --no-tty --command-fd 0 --status-fd 1 --yes --gen-key if ($args{command}) { # child writes to it\'s STDOUT, parent reads this from GPGOUT # child reads from it\'s STDIN, parent writes commands to GPGIN # we use open3 to connect parent GPGOUT and GPGIN to child STDOUT and STDIN my ($gpgcmdfd, $gpgoutfd) = (fileno STDIN, fileno STDOUT); my $gpgarg = "--no-greeting --with-colons --no-tty " . "--command-fd $gpgcmdfd --status-fd $gpgoutfd --yes"; my $cmd = "$self->{gnupg_path} --homedir $self->{homedir} $gpgarg $args{command}"; if ($self->{debug}) { print STDERR "$cmd\n"; } # read perldoc perlipc, .... and weep? # prone to deadlock among other errors BUT ... # know that gpg iface is fixed, don't write until expected GPG end string my $pid = open3(*GPGIN, *GPGOUT, *GPGERR, $cmd); #my $pid = open(GPGCMD, "|-"); #my $pid = fork; die( "error forking: $!" ) unless defined $pid; if ($pid) { # parent # Parent # talk to child # read from GPGOUT and out to GPGIN (connected with open3 to child STDOUT and STDIN) # child write to STDOUT, parent read from GPGOUT, (this dup to STDOUT also?) # parent write GPGIN, child read from STDIN my $key; while (){ #foreach $args if match write, talk to gdb #$self->{error} = $_; #if ($self->{debug}) { # print STDERR "From gpg: $_"; #} my $matched = 0; foreach $key (keys(%args)) { if (!m/command/ && m/$key/) { $matched = 1; if (!defined $rethash{$key}) { $rethash{$key}=0; } else { $rethash{$key}++; } if ($self->{debug}) { print STDERR "From gpg expected match: $rethash{$key} $key\n"; } my $cmdtosend = $args{$key}; if ($cmdtosend ne "") { my @cmdlist = split (/\n/,$args{$key}); if ($#cmdlist) { if ($rethash{$key} > $#cmdlist) { $rethash{$key} = $#cmdlist; } $cmdtosend = $cmdlist[$rethash{$key}]; } else { $cmdtosend = $args{$key}; } # send response if match print GPGIN "$cmdtosend\n"; if ($self->{debug}) { print STDERR " send to gpg: $cmdtosend\n"; } } } } # we didn't match something in our expected list # this is mostly okay # BUT on occasion we get stuck with GPG waiting for input # in particular if GPG want's to GET something if (!$matched) { if (m/GET/) { $self->{error} = "ERROR: From gpg unexpected GET $_"; print STDERR "$self->{error}\n"; print STDERR "ERROR: aborting gpg :(\n"; $rethash{ERROR} = 1; $rethash{ABORT} = $_; print GPGIN "quit\nquit\nquit\nquit\n"; close GPGIN; } } } } else { # not reached (open3 does exec & child never returns from there) #exec($cmd); # a forked (not forked with open2 or open3) child would come here exit(); } close GPGOUT; close GPGIN; # TBD is it alright to close fh that might already be closed? while ( ){ #chomp; if (!/gpg: WARNING/ && !/gpg: please see/) { $self->{error} .= $_; } } close GPGERR; waitpid $pid, 0 or die "error while waiting for child to cross the road: $!\n"; } return \%rethash; } sub gen_key() { my $self = shift; my %args = @_; my $ret = 0; # if ($args{email} || $args{comment}) are optional; # if pass "" to expect expect will not send \n to gpg # messy :-7 TBD: fix it. my $email = $args{email}; if (!$email) { $email = " "; } my $comment = $args{comment}; if (!$comment) { $comment = " "; } if ($args{name} && $args{passphrase}) { my $rethash = $self->_expect_gpg( command => "--gen-key", "GET_LINE keygen.algo" => "1", "GET_LINE keygen.size" => "1024", "GET_LINE keygen.valid" => " ", "GET_LINE keygen.name" => "$args{name}", "GET_LINE keygen.email" => "$email", "GET_LINE keygen.comment" => "$comment", "GET_HIDDEN passphrase.enter" => "$args{passphrase}", "BAD_PASSPHRASE" => "", "GOOD_PASSPHRASE" => "", "KEY_CREATED" => "", ); if ( !$$rethash{ERROR} && defined $$rethash{KEY_CREATED} ) { $ret = 1; } } return $ret; }
Oh and speaking of dumping hex jwz :)
About xxd # just dump something (ptr: hex ascii) 16chrs per line $ xxd ../test-protocol-dump.bin 0000000: 2032 3430 302f 4e4f 4e45 0d0a 050a 2d2d 2400/NONE....-- 0000010: 2d2d 2d2d 2d2d 2d2d 0a02 4231 3131 3233 --------..B11123 # -p for plain $ xxd -l 120 -p ~/notes 0a41646420227365742062656c6c2d7374796c65206e6f6e652220746f20 796f7572207e2f2e696e70757472632e0a237365742062656c6c2d737479 # -c for how many chars per line # -l 24 first 24 chars $ xxd -l 24 -c 12 xxd.1 0000000: 2e54 4820 5858 4420 3120 224d .TH XXD 1 "M 000000c: 616e 7561 6c20 7061 6765 2066 anual page f # -r for hexdump to binary $ xxd -r -p ~/testing/IMAGE.plainhex > ~/testing/IMAGE.binary $ cp /usr/X11R6/lib/X11/fonts/misc/10x20-ISO8859-7.pcf.gz .. $ gunzip 10x20-ISO8859-7.pcf.gz $ xxd -c 16 10x20-ISO8859-7.pcf # -c 16 is redundant # there is more than one way of doing things? # in this case much better ways! # we're whacking out "ptr: " part and # translating ASCII ctrl chars 1c 1d 1f to " FS " " GS " " US " $ sed "s/^.*: *//" ~/bin/data.txt | sed "s/1c/20 46 53 20/g;s/1d/20 47 53 0a/g;s/1f/20 55 53 20/g" | xxd -p -r # see man ascii # FS = Field Seperator, GS Group, US Unit $ man ascii 034 28 1C FS 134 92 5C \ 035 29 1D GS 135 93 5D ] 036 30 1E RS 136 94 5E ^ 037 31 1F US 137 95 5F _ $ apropos hex ascii (7) - the ASCII character set encoded in octal, decimal, and hexadecimal hexdump (1) - ascii, decimal, hexadecimal, octal dump iso_8859-1 (7) - the ISO 8859-1 character set encoded in octal, decimal, and hexadecimal iso_8859-15 (7) - the ISO 8859-15 character set encoded in octal, decimal, and hexadecimal iso_8859-2 (7) - the ISO 8859-2 character set encoded in octal, decimal, and hexadecimal iso_8859-7 (7) - the ISO 8859-7 character set encoded in octal, decimal, and hexadecimal iswxdigit (3) - test for hexadecimal digit wide character koi8-r (7) - Russian Net Character Set encoded in octal, decimal, and hexadecimal text2pcap (1) - Generate a capture file from an ASCII hexdump of packets xxd (1) - make a hexdump or do the reverse $ hexdump -e '"%07.7_ax " 8/2 "%04x " "\n"' headoocalcrules_engr.csv 0000000 4527 5252 524f 2c27 2722 d6d3 cbc1 c1cc # >;) Histogram >;) $ hexdump -e '1/1 "%02x " "\n"' headoocalcrules_engr.csv |sort |uniq -c
uuencode alphabet: `!"#$%&'()*+,-./0123456789:;<=>? @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]~_ _almost_ matches ascii ? #20-40: !"#$%&'()*+,-./0123456789:;<=>? #40-60: @ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_ #60-80: `abcdefghijklmnopqrstuvwxyz{|}~ # if system had not got standard ascii table ... ! :) hmm well now then # uuencoded message would look different but work fine now wouldn't it? # 64 chars here: mime or base64 alphabet: #00-19: ABCDEFGHIJKLMNOPQRSTUVWXYZ #1a-33: abcdefghijklmnopqrstuvwxyz #34-3d: 0123456789 #3e-3f: +/ #padding: = // in c // best to have const string lying around static const char base64alpha="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="; return base64alpha[i]; // more fun to calculate every time, NOT more efficient in any imaginable way r=(i<0x1a)?'A'+i:(i<0x34)?'a'+i-0x1a:(i<0x3e)?'0'+i-0x34:(i<1)?'+':'/'; mime encoding mpack munpack: convert 8 bit byte stream to 6 bit stream uuencode same thing -ish # mime encoding is base 64 encoding kindof uuencode only 7bits, not 6 bits # Header says more about file contained, # e.g. how to handle it, checksum Content-Type: image/jpeg; name="jeschsmall.jpg" Content-Transfer-Encoding: base64 Content-Disposition: inline; filename="jeschsmall.jpg" Content-MD5: 8EJCtYG4bWHsj0c0PraXZw== #so uuencode 3 bytes => 4 mime bytes echo "foo" |xxd 0000000: 666f 6f0a foo. #binary uuencoding (chars have 8 bits) echo "foo" |xxd -b 0000000: 01100110 01101111 01101111 00001010 foo. # split into 6 bit chars for uuencoding 011001 100110 111101 101111 # map using mime charmap (or uuencode map) # uuencode start with e.g. begin 660 filename.txt # uuencode map => add 0x32 0b100000 each char # uuencode => add count char to start every line # usually M (M = 77 decimal = 0x4d, 77-32 = 45 8 bit ascii chars per line after decode) # 45 * 8 = 360 decoded bits 360 / 6 = 60 encoded chars # last line different count usually # uuencode => finish with `\nend # uuencode higher level also then # handles files split into chunks, # multiple uuencode blocks per file, # different uuencode header standards
I've messed a bit with animated gifs.
Obfuscated C code contest and the like (obfuscated perl - aughhh!) of course make for beautiful reading.
The Annals of Improbable Research
is good fun,
have you seen the
Universal History Translation Project
? Yayyy! look! Kudos :) translations using Obfuscated C entries to
braille,
morse and
pigdin. Read, enjoy, remember, saveas, webgrep, download, compile, translate, mail, reply, excellent wonderful gratification. :)
The History of the Universe in 200 Words or Less
by Eric Schulman
National Radio Astronomy Observatory
Charlottesville, Virginia
Quantum fluctuation. Inflation. Expansion. Strong nuclear interaction. Particle-antiparticle annihilation. Deuterium and helium production. Density perturbations. Recombination. Blackbody radiation. Local contraction. Cluster formation. Reionization? Violent relaxation. Virialization. Biased galaxy formation? Turbulent fragmentation. Contraction. Ionization. Compression. Opaque hydrogen. Massive star formation. Deuterium ignition. Hydrogen fusion. Hydrogen depletion. Core contraction. Envelope expansion. Helium fusion. Carbon, oxygen, and silicon fusion. Iron production. Implosion. Supernova explosion. Metals injection. Star formation. Supernova explosions. Star formation. Condensation. Planetesimal accretion. Planetary differentiation. Crust solidification. Volatile gas expulsion. Water condensation. Water dissociation. Ozone production. Ultraviolet absorption. Photosynthetic unicellular organisms. Oxidation. Mutation. Natural selection and evolution. Respiration. Cell differentiation. Sexual reproduction. Fossilization. Land exploration. Dinosaur extinction. Mammal expansion. Glaciation. Homo sapiens manifestation. Animal domestication. Food surplus production. Civilization! Innovation. Exploration. Religion. Warring nations. Empire creation and destruction. Exploration. Colonization. Taxation without representation. Revolution. Constitution. Election. Expansion. Industrialization. Rebellion. Emancipation Proclamation. Invention. Mass production. Urbanization. Immigration. World conflagration. League of Nations. Suffrage extension. Depression. World conflagration. Fission explosions. United Nations. Space exploration. Assassinations. Lunar excursions. Resignation. Computerization. World Trade Organization. Terrorism. Internet expansion. Reunification. Dissolution. World-Wide Web creation. Composition. Extrapolation?
182 words to be precise.
How to torture palmtops - or perhaps graffiti designers.
And some other palm stuff ... what apps do I use? Evolving ....
201 if we include the title and credit.
Palm is mooi
Life
A mystery to most. Can _you_ solve it? Without instructions.
Le ASCII Mandelbrot
Always a passion of mine.
CTO! yuk yuk yuk! *grin*
Sorry, can't work perl on GeoCities. Perl is faster - but I've made it work a bit harder. Crashes Netscape regularily if you try to resize/reload often. Educational about Java and the timecount. (2.5k per sec) (yeah right!)
Not even half obfuscated enough :( But was written in couple of minutes. (including comments!) #includemain() { /* +-------------+ |\ | | ox,oy | | | | | +-------------+ sx*sy - width*height dx - sx/xres dy - sy/yres using deltas => go deeper will have resolution problems :- BUT I'm doing ASCII! so :-P''' x increases LtoR y decreases TtoB gives normal x/y plot */ int i,px,py; float x,y,xx,yy,c,nx,ny; int xres=80; int yres=50; float sx=4.0; float sy=4.0; float oy=2.0; float ox=-2.0; float dx,dy; dx=sx/xres; dy=sy/yres; for(py=0,y=oy;py@yres;py++,y-=dy,printf("\n"))for(px=0,x=ox;px@xres;px++,x+=dx){ i=0; nx=x; ny=y; for(xx=nx*nx,yy=ny*ny;i@60 && xx+yy@4.0;i++){ xx=nx*nx; yy=ny*ny; nx=xx-yy+x; ny=2*nx*ny+y; } printf("%c",i+' '); } }
Interactive Geometry? Orbital Pinball?
Find Prime numbers sci.math faq Largest Primes utm.edu primes Software Indexes and Programs bios Cosgrave Gallot (software) Proth.exe - by Yves Gallot, A Win95 program for finding very large primes GIMPS proj for (lin/win) pentiums
I try join seti@home dspgroup from work but fewkin proxy won't co-operate. :( so .....
#!/bin/ksh #Run one instance of seti@home in seti@home home. export HTTP_PROXY=your.poxy.proxy.server:port SETIATHOME_HOME=/wherever/you/put/setiathome cd $SETIATHOME_HOME while [[ 1 ]] do { $SETIATHOME_HOME/setiathome mv $SETIATHOME_HOME/work_unit.txt $SETIATHOME_HOME/proxy_work_unit.txt tail -n +11 $SETIATHOME_HOME/proxy_work_unit.txt > $SETIATHOME_HOME/work_unit.txt } done
See some map-server torture somewhere here. Experiments with Java applets: Rough map of Ireland
Antipatico HOME |