Do Mind The Gap Well yes, I do mind the gap

21Aug/100

Peta in a nutshell

Not by me, it's from my stuff folder (aka "Folder that contains random stuff I find on the net, which is good enough to actually save").

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • StumbleUpon
  • Twitter
  • email
29Jul/100

Another tale fromt he attic

I just found another batch of old stuff I thought I threw out: Here are some goodies from back when we were doing Delphi in IT class.
First of all here's an easy one: An RPN Calculator. The actual assignment was "program a calculator", but I thought that to be too easy, so I made it more difficult for me.

However, the really goody of this is my Sudoku Game (I thing I was one of the few people who actually even got this far in the class, most where stuck with understanding DataTypes and the such, as it we started from zero and it was within the first 6 month of actual programming). I dare you to understand how this works:

procedure TSudoku.Generate;
var
  I, J, K, R: Integer;
  B: Boolean;
begin
  // initialize random
  Randomize;
  // do really ugly stuff
  // warning: no comments and it's __really__ hard to get
  for I := 0 to 8 do
    for J := 0 to 8 do
      Field[I, J] := 0;
  I := -1;
  J := -1;
  while I < 8 do
  begin
    R := 0;
    Inc(I);
    J := -1;
    while J < 8 do
    begin
      Inc(J);
      K := 10;
      repeat
        Dec(K);
        Field[J, I] := Random(9) + 1;
      until IsAllowed(J, I) or (K = 0);
      if R > 9 then
      begin
        Generate;
        Exit;
      end;
      if K = 0 then
      begin
        Inc(R);
        B := False;
        for K := 1 to 9 do
        begin
          if not B then
          begin
            Field[J, I] := K;
            if IsAllowed(J, I) then
              B := True;
          end;
        end;
        if not B then
        begin
          for K := 0 to 8 do
            Field[K, I] := 0;
          J := -1;
        end;
      end;
    end;
  end;
  Solution := Field;
end;

Yes, this is why you need to comment your code. Or why I need to comment mind. Whatever.
Source Code (and Binaries): Calc and Sudoku

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • StumbleUpon
  • Twitter
  • email
28Jul/100

Calculate Everything in PHP

Here's something I wrote (not too long ago) for a friend and co-worker of mine, Benjamin Haettasch (I don't think he updates his website really). He wanted to do some boring math crap in PHP to demonstrate to his math class and needed a "calculate everything you want with it" function. Which I promptly delivered:

<?
	/*
	 *	DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
	 *	Version 2, December 2004
	 *
	 *	Copyright (C) 2010 Patrick Lerner <i@domindthegap.co.uk>
	 *	Everyone is permitted to copy and distribute verbatim or modified
	 *	copies of this license document, and changing it is allowed as long
	 *	as the name is changed.
	 *	
	 *	DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
	 *	TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
	 *
	 *	0. You just DO WHAT THE FUCK YOU WANT TO. 
	 */
 
	// i take 50% of the credit for this function
	// 25% goes to the creator of the echo command
	// and the last 25% go to the creator of the bc command
	function c($s)
	{
		return shell_exec('echo "'.$s.'" | bc -l');
	}
	echo c('2+3');
?>

Note: DO NOT USE THIS WITH USER INPUT. IN FACT, DON'T USE IT AT ALL. IT'LL FUCK YOU UP.

Also it only runsĀ  on *nix. I consider this a feature.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • StumbleUpon
  • Twitter
  • email
28Jul/100

More Stuff from the attic

So I was cleaning out the virtual attic, and I came across some more stuff from the past year.

First of all here's an AVL-Tree Class in both Python and Java. It's fairly simplistic and cannot delete leafs, so it's really just a proof of concept (Prove my teacher that I understood the concept). The actual assignment was only the Java Part, but because Java sucks I did it in Python (took me 2 hours, which apparently is the time Eclipse needs to warm up alone) first and later ported it to Java.

Be aware though that the Python Version is approximately 200 times slower than the Java Version.

Source Code: Java and Python

Secondly I found a little simulation of the Enzyme substrate process (or whatever) I created for one of our biology teachers for a demonstration in here "teacher's examination". It's written in Delphi and only available in German. However, I believe it's kind of self explanatory.

Source Code (and Binary): here

I even found a showcase Youtube Video of it on my old Youtube Channel:

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • StumbleUpon
  • Twitter
  • email
28Jul/100

Guess a Number Word Macro

As Part of the Series "Stuff I found in the Attic" (there is no such series, don't bother searching), I have this for you: The infamous Guess the Number Game as a *fun* Word Macro.

Why would I write a Word Macro you ask? Well back in '09 we had to do school internships and I worked at the IT department of our local government administration (Kreisverwaltung as we call it). Basically my job consisted of unpacking and installing a hell of a lot of displays for various computers.

Apart from that I installed software on some people's smartphones and reworked a word macro they use to print some sort of personalized instructions for the computer terminals (as in "Hello X, you username is lolcat.lastname and you passwort is xxx.").

This of course was new to me (why work with VBS when one can avoid it, right?). So, long story short, I was sitting there on my thin client with limited rights and bored as hell and wrote a little game to entertain me (Actually the entertaining part was the writing, not the actual playing).

Source Code here (I like me some GitHub btw)

And yes, it does have a swear-mode. Don't ask how I got this idea.

Share and Enjoy:
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • Add to favorites
  • StumbleUpon
  • Twitter
  • email