Sunday 21 December 2008
Wednesday 10 December 2008
Saturday 29 November 2008
Monday 24 November 2008
Saturday 15 November 2008
Thursday 13 November 2008
Monday 3 November 2008
Sunday 26 October 2008
Saturday 18 October 2008
Friday 10 October 2008
Saturday 13 September 2008
Wednesday 10 September 2008
Sunday 7 September 2008
Saturday 23 August 2008
Friday 22 August 2008
science week
"I like that, sir, if I may say so, because it’s a very good thing, indeed it’s one of the things aimed at by this Academy, that we should not fall into the error of thinking that science began this morning." :- Robert Menzies prime minister of Australia opening the Shine Dome (aka Becker House, Jack Becker gave 100K of 1961 pounds and was dumped for John Shine's 1M 2000 AUD, cheek !)
Thursday 21 August 2008
Tuesday 19 August 2008
Tuesday 12 August 2008
Monday 4 August 2008
Friday 1 August 2008
Friday 25 July 2008
Tuesday 22 July 2008
Friday 18 July 2008
Zigzag in C
Here is the zigzag decoder in C
//=======================================================
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main (int argc, char *argv[]) {
const int ArraySize= 10001 ;
char cryptStr[ArraySize];
int rowlen,r,newrow;
char array[ArraySize];
if ( argc < 3 ){
printf("%s\n","zigzag_d rowlen cryptmessage");
} else {
rowlen = atoi(argv[1]) ;
strcpy(cryptStr,argv[2]);
//adjust for zero-numbering
rowlen-- ;
//init the array
for (r=0;r <=ArraySize ;r++){ array[r]=0; }
int rowIndex =0;
int tempIndex=0;
int arrayLen = strlen(cryptStr)-1;
r=0;
newrow=0;
while(r <= arrayLen ){
if (newrow == 1 ) {
// new row
rowIndex++;
tempIndex = rowIndex;
array[tempIndex] = cryptStr[r];
if (rowIndex == rowlen) {
tempIndex = tempIndex+2*rowlen;
} else {
tempIndex = tempIndex+(2*(rowlen-rowIndex));
}
r++;
newrow=0;
} else {
if((rowIndex > 0 ) ) { //don't do on first row
if(newrow==0) {
array[tempIndex] = cryptStr[r];
r++;
tempIndex = tempIndex+2*rowlen-(2*(rowlen-rowIndex));
if (tempIndex >arrayLen) { newrow =1; }
}
}
if(rowIndex != rowlen) { //don't do on last row
if(newrow==0){
array[tempIndex] = cryptStr[r];
r++;
tempIndex = tempIndex+(2*(rowlen-rowIndex));
if (tempIndex > arrayLen) { newrow =1 ; }
}
}
}
}
printf("%s\n", array);
}
}
//=====================================================================
Sunday 13 July 2008
Zigzag Cypher
The Zigzag cypher (also known as a Rail Fence is a simple transposition scheme and not very strong, this is just an exercise in tinkering.
First here is the encoder:
After some trial and error the decoder
And a few lines for a test script
First here is the encoder:
#!/usr/bin/perl
$rowlen = @ARGV[0];
$message = @ARGV[1];
if ( @ARGV == 0) {
$message="CHARLIETHEWONDERBUDGIE";
$rowlen =6;
}
$rowlen -- ;
@letter = split '', $message;
$dir =0;
$index =0 ;
for ($r=0;$r<= @letter ;$r++){
@array[$index]=@array[$index].@letter[$r];
if($dir == 0) { $index++; }
if($dir == 1) { $index--; }
if ($index >$rowlen ) {
$dir = 1 ;
$index-=2;
}
if ($index <0) {
$dir=0;
$index+=2;
}
}
for ($r=0;$r<= $rowlen ;$r++){
print @array[$r] ;
}
print "\n";
After some trial and error the decoder
#!/usr/bin/perl
sub unzig {
#adjust for zero-numbering
$rowlen-- ;
@letter= split '', $cryptStr;
for ($r=0;$r <= scalar(@letter) ;$r++){
@array[$r]=" ";
}
$rowIndex =0;
$tempIndex=0;
$arrayLen = @letter-1;
$r=0;
$newrow=0;
while($r <= $arrayLen ){
if ($newrow == 1 ) {
# new row
$rowIndex++;
$tempIndex = $rowIndex;
@array[$tempIndex] = @letter[$r];
if ($rowIndex == $rowlen) {
$tempIndex = $tempIndex+2*$rowlen;
} else {
$tempIndex = $tempIndex+(2*($rowlen-$rowIndex));
}
$r++;
$newrow=0;
} else {
if(($rowIndex > 0 ) ) { #don't do on first row
if($newrow==0) {
@array[$tempIndex] = @letter[$r];
$r++;
$tempIndex = $tempIndex+2*$rowlen-(2*($rowlen-$rowIndex));
if ($tempIndex >$arrayLen) { $newrow =1; }
}
}
if($rowIndex != $rowlen) { #don't do on last row
if($newrow==0){
@array[$tempIndex] = @letter[$r];
$r++;
$tempIndex = $tempIndex+(2*($rowlen-$rowIndex));
if ($tempIndex > $arrayLen) { $newrow =1 ; }
}
}
}
}
for ($r=0;$r <= scalar(@letter) ;$r++){
print @array[$r];
}
print "\n";
} #end sub
#main
$rowlen = @ARGV[0];
$cryptStr = @ARGV[1];
if ( @ARGV == 0) {
print "call with ./zigzag_d.pl rowlength cryptmessage \neg. ./zigzag_d.pl 3 COPATGAHRRY\n";
#do a demo
$cryptStr="WECRLTEERDSOEEFEAOCAIVDEN";
$rowlen =3;
unzig;
} else {
#there was command line input
unzig;
}
And a few lines for a test script
./zigzag_e.pl 3 CARTOGRAPHY
./zigzag_d.pl 3 COPATGAHRRY
./zigzag_e.pl 4 THISISENCRYPTEDWITHTHEZIGZAGCYPHER
./zigzag_d.pl 4 TETHGPHSNPETTIZYHIICYDIHZACESRWEGR
./zigzag_d.pl 6 CWIHEOGEAHNDRTDULEEBIR
./zigzag_d.pl 10 CERHDYTOHEGASSVAOOEFCLWADANR
Monday 30 June 2008
Saturday 5 April 2008
Thursday 27 March 2008
Sunday 16 March 2008
OpenBiblio demo
I have been tinkering with OpenBiblio library software and deployed a demo... Later, had to remove the demo due to unwanted hacking (this means you q5c.ru). Thanks for nothing.
Wednesday 12 March 2008
Friday 29 February 2008
Skink
This charming little skink found his way inside, here he is prior to release
Back in the garden
A little closer (he was lying doggo)
Back in the garden
A little closer (he was lying doggo)
Thursday 28 February 2008
Sunday 3 February 2008
echo "echo \"hello world\"" >hello.sh
The latest XKCD is even funnier than the normal high standard.
Saturday 19 January 2008
Friday 18 January 2008
Kangaroo Cargo Bike
Chituma have got these neat cargo bikes, they are selling them with electric motors fitted but also available as pedal-only. The pedal unit is going for $795 AUD.
Subscribe to:
Posts (Atom)