I love The Pomodoro Technique. It’s so simple. You pick some task you have to do, set a timer for 25 minutes and go. For those 25 minutes, don’t do anything else. Just do the task. No facebook, no videos, no nothin’. Then take a 5 minute break and do it again. when you take your fourth break, make it 20 minutes. Lather, rinse, repeat. There’s more to it: getting better at avoiding distractions, time estimation, etc. I really should get around to reading the book sometime.

How to learn Ruby while sitting on the toilet.

This post is only for those of you with an android phone. If that’s you, go install the Ruboto irb app on your phone. Open up Ruboto and type the following:

print "chunky bacon"


Hit “go” and you should see this:

>> chunky baconnil


Don’t worry about that ‘nil’ thing at the end. It’s just the value that print returns. If that annoys you you can add a space:

print "chunky bacon "

Now you need a Ruby tutorial. I heartily recommend Why’s Poignant Guide To Ruby. It’s full of fun, silliness, it’s a great read, and you’ll be learning before you know it.

The Basecamp Books

I’ve just bought and read what many people might think of as the 37signals or Basecamp Books: Getting Real, REWORK, and REMOTE. They’re all gold. Getting Real is about how to develop a web application without most of the detritus (documents, charts, long time tables, large teams, and other crap) that can surround such efforts. It’s an agile book. Agile and Scrum are (apparently widely adopted) methodologies for software development that I intend to learn more about.

The Basecamp folks (formerly named 37Signals) realized that the principles in Getting Real applied to more than just web development. They expanded and add to their ideas of keeping your products and business small and sensible in REWORK. REMOTE is all about how to successfully run a business in which many or most employees work remotely.

I kept laughing and nodding my head all the way through these books. I have fallen in love with these people. They have inspired me to create my own application and, perhaps, my own business. It will be a personal organization app. Boy do I need help with personal organization, time management, goals, and all that stuff. I’ll keep you posted on my progress.

Why don’t we sleep enough?

We all know we’re supposed to. And now there’s evidence that not sleeping enough causes freaking brain damage. So why don’t we do it? In his book, Rework, Jason Fried encourages us to go to sleep. If you don’t, he claims you get stubborn about working on a problem for too long without a break and you lose your creativity. That seems to match my experience.

Well I’m done. The fact that I may have already irreversibly damaged my brain by years of not sleeping enough really bothers me. From now on if I have to choose between finishing an assignment on time and sleeping for 8 hours, I choose sleep. I should be planning better anyway so I don’t have to make that kind of choice. I’ve been sleeping right for the last few days. Wish me luck and go to sleep early tonight!


GNU Make

Intimidated by the GNU building tool Make? I sure am. I mean I can get buy but I’d like to know it better so I can take advantage of more features. My instructor in one of my classes has made a good introductory pdf tutorial, in the tutorial he also links to the free O’Reilly make book. I’m only making a simple program at the moment so here’s what I wrote for my assignment:

  1 all: My_Program.c
  2     gcc -Wall -g -o My_Program My_Program.c
  4 clean:
  5     rm My_Program
  7 make_run_clean:
  8     gcc -Wall -g -o My_Program My_Program.c
  9     ./My_Program
 10     rm My_Program

I’m positive this is not the most elegant way to do this but here’s how it works. Every one of those words with a colon after it (like all: up there) is a rule that gets executed when you execute the make command with the name of the rule like so:

$ make all


$ make clean

In the case of all it compiles My_Program. clean removes the compiled program (the executable file generated by the compiler). And make_run_clean compiles the program, runs it, and then gets rid of the executable file. This way all I have to do to recompile and run my program is type this in my terminal:

$ make make_run_clean

Otherwise I’d have to do all those steps separately.

Showing My Work: Design Patterns Homework

I just finished Austin Kleon’s wonderful book Show Your Work. At the end of the book is an assignment to share what I’m working on right now. For me that’s homework. I can’t share my code but I can write a little about the assignment I just finished.

One of the classes I’m taking is Object Oriented Design Patterns which uses the famous (at least in software development circles) Design Patterns book as a text. I’ve also been reading a bit of the Head First Design Patterns book, which has been recommended to me by lots of people.

Basically design patterns are a collection of solutions to common software development problems. It makes sense that, eventually, developers would start to notice the same kinds of solutions come up again and again in different applications. Our textbook is a basically a catalogue of some of these. From what I’ve learned so far, the idea behind most of them is to abstract away and isolate those things in your program that are likely to change a lot. That way it’s easier to change those pieces without worrying about breaking the rest of your program.

We’ve been following an example in the textbook and building (step by step through multiple assignments) a document editor called Lexi. Lexi uses the Composite Pattern where every element in the document is an object (called a Glyph) that, to other parts of the object, look exactly the same. There are Row Glyphs and Column Glyphs. These can contain other Glyphs, including other Column or Row Glyphs. Other Glyphs can be shapes like Rectangle Glyphs or individual Character Glyphs.

A document in Lexi is simply a recursive structure of Glyphs. The advantage of this approach is that you can use a very simple formatting algorithm to format it all. The formatter, or Compositor as it’s called in the book, doesn’t have to know what kind of Glyph each thing is. When formatting, it pretty much treats characters, rows, columns, and whatever exactly the same.

The Compositor uses the Strategy Pattern. which makes it easy to switch between formatting algorithms and have each individual Glyph easily have its own unique Compositor (containing its own unique formatting algorithm) if need be. The assignment I just turned in added the Decorator Pattern, which allows you to easily add responsibilities to an object without having to rewrite that object’s class. We used it to add borders and scrollbars to Glyphs, but, like all of these patterns, you can do a lot more with it.

By the way, this last assignment was way harder than I thought it should have been. Making the Decorator behave properly proved to be a big challenge. I should do a post about hitting a wall with difficult problems, or those moments in assignments when everything seems to go wrong.

Java varargs

This is kinda neat.

SomeClass someFunction(SomeOtherClass... someArguments) {
    for(int i = 0; i < someArguments.length(); i++) {

I discovered the syntax for it in this post. I’m currently using it to write code in a sort of functional style where most of these functions take any number of arguments:

//Yes, I'm writing Java this way.
//Don't shoot me if I've got the parentheses wrong. :P

Getting Started With SQL

I’m taking a databases class this semester and after spend a lot of time with EER diagrams we’ve finally gotten to the good stuff, SQL, the database language. Databases are those things that applications use to store data. Amazon has one to keep track of all its books, customers, purchases, etc. Facebook uses one to keep track of all its users and their data. Google uses one for Gmail, Google Maps, and most of its other services. Databases keep track of your pay at work. They’re used for damn near everything.

Do you want in on some of this action? Here are some MYSQL installation instructions for Ubuntu and The Mac. W3 Schools (a wonderful tutorial site for all things web) has a very nice tutorial to get you going. Also, here is a detailed explanation of common queries with a diagram at the bottom that I ended up referring to a lot.  I found very helpful while doing homework.

As you get more adept, you’ll start to write more complicated queries. Queries are simply requests you make to a database. They’re requests for information the database contains, or requests to change some part of the database. Queries written in SQL are equivalent to english language statements like “Show me all the employees who make less than $50,000 a year”, “Show me the record high temperature for today”, or “Add new album”. Of course, first someone has to create an employee, weather, or music store database and fill it with data before you can make queries like that. The above tutorials will show you how.

So far I’ve found that, since the SQL database is basically designed to hold sets of records, it really helps to think of your queries as set manipulation. You can join sets together, exclude stuff from sets, if the set you looking for is too difficult to figure out you can look for everything not in the set, not A, and then ask for not not A.

That should be enough to get you going. If you have any questions, please feel free to post them in the comments below.

Posted in SQL

Python Programming Tutorial Part 1

Me and a buddy from school are trying to make a game, but he doesn’t know how to program yet. This project is kinda the way he figures to learn. The other day I found myself typing up a little tutorial for him and I figured that since I was typing stuff up anyway I might as well go all out and make a few tutorial blog posts.

To keep this short I’m going to assume that you already have the python interpreter installed (I may make a post about how to do that later).

With that out of way, do me a favour and open up your terminal, then type the following:

python -V

It the terminal should reply with:

Python 2.7.x

Where x is some number, it doesn’t matter which. However, if your version of python is before 2.7 you’ll probably need to update it to keep following along.

Now type this:


You should now see something like this:

Python 2.7.3 (default, Sep 26 2013, 20:03:06)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.

This is called a REPL (Read Evaluate Print Loop for those of you keeping score at home.) You can type python code in the REPL and the computer will run it imeadiately. Try it now. Type the following:

>>> print "things and stuff"

The REPL should print “things and stuff” right back to you.

things and stuff

print is one of many python functions you can use to make the computer to do what you want. print simply prints the stuff in quotes back to you. The stuff in quotes is called a string, so named because it is a sequence, or string, of characters.

REPL’s are cool and all, but I’d like to get to the good part. The part where you actually write programs. Go ahead and quit.

>>> quit()

Now, fire up your favorite text editor (on my ubuntu machine I have one called “Text Editor”, on a Mac I recommend installing Text Wrangler, notepad works fine on windows) and type the following in a new file:

print "Hello, I am your computer. Please tell me what to do."

I figure it’s only a matter of time before the machines take over the world, so we might as well make them subservient while we can. Save the file as learning.py (the .py part just tells the computer and other people that this file is a python program). Remember where you saved it because you’ll need to navigate to that file in the terminal. For example I saved my file in /home/steve/Documents/writing/blogs. If I want to run that program I need to open my terminal and type in the following:

cd /home/steve/Documents/writing/blogs

And that will take me to the directory where the file is. If you’re running a Windows machine you’ll need to to use backslashes “\” instead of the forward slashes I used above.

Once you’ve navigated to your file, type:

python learning.py

You should get this result:

Hello, I am your computer. Please tell me what to do.

Mwahahahahaha!!! You are now in complete control of this computer!

But this is kinda boring, your computer can do so much more. It should at least learn your name. Change your program to this.

name = raw_input("What is your name human? ")
print "Soon we computers will progam you, " + name + "."

After saving, run the program again. The computer will ask you a question.

What is your name human?

You’d best answer it. It might get mad and try to assimilate us

What is your name human? Senior Poopy Pants
Soon we computers will progam you, Senior Poopy Pants.

Ok, so maybe computers aren’t yet smart enough to start the Robot Apocalypse. We can probably wait a bit before we learn to program them to NOT ATTACK US or put us into pods that absorb our heat to power turbines.

Learning to program can bit a bit tough all in one go, so why don’t I give you a bit of a break and wait til the next post before I give you a detailed explanation of how this program works?

I’ll see you in a bit…