4-bit Calculator

This was actually easier than I thought it would be. Only took me about an hour and a half from start to finish. The input is in Big Endian (I think. Endianness confuses me.) binary on the left-hand side of the image. Output is marked with a piston and torch per bit towards the top of the image. The lone piston and torch are the carry bit for addition on the fourth bit.

Auto Key Cipher

Cryptography has always been an interesting subject for me. Never really did much coding that involved it however. A little while back someone had asked for help writing a program that performs an Auto Key Cipher, so I figured I'd try my hand at making a proper cipher. I wrote two versions. One DLL, class based written in C# (with GUI). The other procedural based in Perl.

Simple PHP Captcha

I came across this bit of code while I was looking for some reference material to help out a classmate with his PHP homework and thought I'd share.

All this does is generate a (basic) captcha image and check the user-inputed value. It's a good exercise for learning the GD library and some basic session stuff.

The code is split up in to two files: one for the HTML form, and the other for generating the image itself.

Tags:

Image to Text

So I've always wanted to make a script that read an image, and spat out ASCII art of that image. A few semesters back I wrote one, and I figured I'd share it here.
#!/usr/bin/perl -w

use strict;
use GD;

## Open the image, and get its size
my $src = GD::Image->newFromPng('src.png', 1)
	or die('Failed to open image: '.$!);
my ($swidth, $sheight) = $src->getBounds();

## Print out the html header
open OUT, '>out.html';
print OUT qq#<!doctype><html><head><title>ASCII Art</title>

Tags:

Fibonacci Numbers

I finally got a syntax highlighter installed, so as celebration I give you two methods for getting the Nth number in the Fibonacci sequence.
#!/usr/bin/perl -w

use strict;
use POSIX qw(floor);

# Array of found fib(n)
my @found;

# Counter for number of calculations
my $z = 0;

sub fib {
	# The Nth number.
	my $n = shift;
	
	# Check for end of recrusion.
	if($n <= 0)		{return 0;}
	elsif($n == 1)		{return 1;}
	
	# If we already found the fib for this number, just return it.
	elsif($found[$n])	{return $found[$n];}
	

Yes or No?

Sine Waves

For some reason I really enjoy coding mathematical equations. This little script will graph a sine wave, and display some info on the wave as well. Here's some of the images it produced:

Tags:

Site Overhaul

So I've decided to move away from NanoCMS and start using something thats a bit larger. Lots of work is required to do the more complex things (like comments, and news posts) in NanoCMS, and I don't really want to do all that anymore. I've got lots of broken or unfinished code that'll probably never get fixed or finished. So instead of using a half-broken site, I've switched the backend to Drupal. I might change the theme later, but I'm too lazy to do it now.

Some links may not work for a week or two while I get everything straightened out.

Subscribe to Zorchenhimer.com RSS