C++ 2D Array Class

Download the source code for this example here

Built in 2D arrays have the problem that they don't work with the standard library. Writing a normal class to represent a 2D array has the problem that you cannot use the built in style of operator, operator[][].

A general approach to solve this issue to ensure that the 2D array class operator[] returns a class that also overloads operator[], and hence can be used to access the underlying data. To solve the issue of not being able to use the standard library, the class will implement a custom random access iterator. I provide the implementation of this approach below.

Continue reading

Posted in Uncategorized | Leave a comment

Simple Up/Down counter with JK Flip Flops

Every few months I want to build a state machine circuit, and I always have to think for a few minutes about how to use them, I always forget how to do the excitation table...

So I am going to detail the very simple steps of how to build a very simple sequential logic circuit, hopefully so I can refer back to it again in the future whenever I forget...

To illustrate it I will design a simple up/down counter. The counter works by if we have an input of 0, it counts up, if we have an input of 1 it counts down. Whenever it the counter overflows or underflows we want it to output a 1, otherwise output a zero.
Continue reading

Posted in electronics | Leave a comment

A Brainfuck Interpreter in Javascript

Happy New Year everyone! I was attempting to sleep around 5am last night and found I could not, and hence I was reading up wikipedia on one of my favorite topics, esoteric programming languages. I absolutely love them! They are so... useless. And hence fascinating.

Which brings us to Brainfuck. Its a very simple esoteric programming language, and I thought, why not write an interpreter in Javascript. Its simple! (only took around 25 minutes to write the whole thing) and randomly fun...

To see the working interpreter, Continue reading

Posted in esoteric, programming | Leave a comment

A Simple Tower Defense Game in Javascript

Been playing around with Javascript the last two days, and wrote up a simple tower defense game. If you aren't familiar with tower defense, have a quick read of this to familiarize yourself with the genre.

You can play the completed version of this game here. I haven't used any external images to complete this game, just pure CSS, HTML and Javascript. Playing around with the game will help you understand the post below, so give it a try.
Continue reading

Posted in css, html, javascript, programming | 1 Comment

PHP Database Abstraction Layer

Communicating with the database is one of the most frequent tasks one undertakes when using PHP. As such its important to have a ready to go abstraction layer to automate SQL queries.

I have written a small selection of php methods to abstract and automate this process.
Continue reading

Posted in php, programming, sql | Leave a comment