Friday, April 13. 2012
Ubuntu - application taskbar
Wednesday, April 11. 2012
Self replicating programs
I read an interesting article today "Zip Files All The Way Down" about self reproducing programs and, having some free time, decided to cheat a bit by doing it in JavaScript. Its actually more than a bit of cheating since you can get the entire JavaScript code from the DOM. So here's an HTML file that displays itself when loaded in the web browser:
<html>
<body onLoad="init()">
<script id="src">
function init()
{
var str = tag('html');
str += tag('body onLoad="init()"');
str += tag('script id="src"');
str += pretty('src');
str += tag('/script');
str += tag('div id="self"');
str += tag('/div');
str += tag('/body');
str += tag('/html');
document.getElementById("self").innerHTML = str;
}
function tag( str )
{
var lt = String.fromCharCode(38) + "lt;"
var gt = String.fromCharCode(38) + "gt;"
return lt + str + gt + String.fromCharCode(60) + "br" + String.fromCharCode(62);
}
function pretty(id)
{
var src=document.getElementById( "src" ).text;
src = src.replace(/^\r*\n/gi, "");
src = src.replace(/\r*\n/gi, String.fromCharCode(60) + "br"+String.fromCharCode(62));
var blank = String.fromCharCode(38)+"nbsp;"
var indent = blank + blank + blank + blank;
src = src.replace(/\s\s\s\s/gi, indent );
return src;
}
</script>
<div id="self">
</div>
</body>
</html>
Yeah, I know, not really something to write home about.
Another accomplishment that shows the degree to which I have sunk was shrinking the simple JavaScript game that I wrote to 1,122 bytes.
Last time I wrote a game with such a small footprint was on my VIC20 back in 1981. Here it is in all it's obfuscated glory.
Monday, April 9. 2012
Recreated JavaScript game
About a year ago, I was in a situation where I was stuck at a location where there were PCs with Windows XP installed with no Internet access and no external software was allowed to be loaded on these PCs.
The only software on these PCs other than what came with the OS was some dedicated professional software.
As a way to pass the time with more interest, I opened a text editor and started coding a quick game in JavaScript to be played on the browser.
The game was completed with less than 100 lines of code - the goal is to remove all the bouncing colored squares by moving the mouse over each one and to do so in the minimum amount of time.
I left the game there to the delight of the people who found a new way to be counter-productive on the job.
There was no way to save the game so I had to recreate it when I got back home. If you want to try playing, just click here - should work on all browsers.
Sunday, April 8. 2012
Captain's log, first entry
I'm taking a year off to learn new things. This will record my experiences and thoughts.
To start things differently I'm using Serendipity instead of Wordpress.
Today I looked at various open-source Prezi alternatives. There are some cool works in progress that use HTML5 and SVG to create Prezi-style presentations such as Awwation and Impressionist (both open source, both hosted on github). There is also sozi that uses Inkscape to create Prezi-style presentations using SVG - again - open source.