From the category archives:

Programming

My LOLCode Interpreter

October 31, 2007

LOLCode Book

I had 2 hours to kill so I thought I’d write a LOLCode interpreter.

I know there’s already a few LOLCode interpreters around, but I couldn’t help myself. Plus I’ve always been interested in interpreter design.

It’s still a work in progress at this stage, so a lot of the language hasn’t been fully implemented.

Here are two working programs…

Hello World


BTW the classic hello world program
HAI
VISIBLE "Hello world!"
KTHXBAI

Output:

LOLCode Hello World

Accepting User Input


HAI
VISIBLE "Hello there, what is your name?!"
I HAS A NAME ""

BTW ask for the users name
GIMMEH NAME

BTW welcome the user
VISIBLE "Welcome to LOLCode " N NAME N "!"
KTHXBAI

Output:

LOLCode Accepting User Input

{ 0 comments }

Ron Paul Filter for Reddit

October 30, 2007

If you’re addicted to reddit.com like me, you’ll understand my frustration with all those Ron Paul links. Especially if you don’t live in the US, and don’t really know who the guy is.

If anyone is interested, I’ve written a small Greasemonkey script which hides all reddit links that include the text “Ron Paul”.

To install, download the Greasemonkey file and drag it onto your firefox window.

ronpaul.user.js

{ 0 comments }

PHP Command Line Tip

September 11, 2007

Here’s a quick tip for working with the command line in PHP.

If you’ve ever run a PHP script via the command line, you would have noticed that output from the script is not printed until the script has finished.

If you need your output displayed in real time, you can open a stream to the command line…

$stdout = fopen('php://stdout', 'w');

Simply write any output to the stream and it will be printed on the command line in real time…

fwrite($stdout, "Hello CLIn");

{ 0 comments }

One thing I keep noticing is the use of background noise or clutter in CAPTCHAS. It’s now well known in the OCR (Optical Character recognition) field that background noise can be easily removed by computers. It’s basically useless at hindering spam bots.

It’s so easy that I was able to clean the following CAPTCHA up in only 20 lines of PHP code.

CAPTCHA

Here’s how…

At a glance, you can see the CAPTCHA’s background noise has a blue tint. CAPTCHA RGBLooking at the RGB value of the image in Photoshop, I can see that all parts of the background have a blue value higher than 180.

That’s the only piece of information needed to remove the background.

The code simply loops through every pixel of the image and checks the RGB value of it. If the blue (B) value is higher than 180, color it white.

Here’s the final image. The characters can now be easily separated and identified using OCR software.

CAPTCHA

So you can see why most background noise is basically useless in CAPTCHAS.

{ 0 comments }

Basic 3D Engine Design

August 23, 2007

Ray Casting is a extremely fast method of generating 3D images using high-school level mathematics.
Remember playing Wolfenstein 3-D? This was one of the first games made using the ray casting technique.

The graphics in Wolfenstein don’t even come close to today’s gaming standards; but it was still impressive for it’s time. It was also fast, considering [...]

Read the full article →

Facebook Code Analysis

August 16, 2007

Most developers have now heard about Facebook’s leaked index.php source code, which was anonymously posted here. If you haven’t seen it already, there are a number of links listed on Techcrunch.
I’ve seen a few bloggers criticize Facebook developers for using procedural programming rather than classes and object oriented techniques. I’m not exactly sure why they’ve [...]

Read the full article →

Check Username Availability

August 8, 2007

The goal of a signup form is to quickly convert visitors into registered users. The easiest way to increase your sign up form’s conversion rate is to lower the amount of time it takes to complete.
One way to do that, is to add a “check username availability” feature. Users will often choose conflicting usernames, especially [...]

Read the full article →

Building a Website for your Application

August 2, 2007

So your project is nearly finished, now all you need is a website to get the word out. Unfortunately this stage of the project is often neglected, which is understandable. Programmers want to work on the actual application rather then the website. However, your visitors aren’t going to download your application if they can’t find [...]

Read the full article →

Draggable Windows with Javascript

July 27, 2007

A window is essentially just a floating div. We can make the div draggable using the Script.aculo.us Javascript library.
First, we need to create the window div. Here is the CSS I used.

.window {
  background: #d8e7fe;
  position: absolute;
  top: 200px;
  left: 200px;
  width: 350px;
  padding: 1px;
  -moz-border-radius: 7px;
  border: 2px solid #21416d;
}
.window h1 {
  -moz-border-radius-topleft: 5px;
  -moz-border-radius-topright: 5px;
  padding: 6px;
  display: block;
  background-color: #9cc6ff;
  font-size: 13px;
  margin: 0px;
}

And here is the [...]

Read the full article →

Password Strength Meter

July 25, 2007

Making a password strength meter is simple, there’s no tricky Javascript or AJAX needed, just a simple function and a few divs.
Click to view demo.

I’ve decided to design the function around a scoring system, the stronger the password the higher the score. We can accomplish this with just a few simple IF statements.
function passwordStrength(pass)
{
var score [...]

Read the full article →