git rm’ing all deleted files

Say you deleted a bunch of files and/or folders in a project. Instead of like

git rm path/to/file

or even

git rm -r path/to/folder/*

you could like all

git add -u

and BAM! done.

My “Beginning Game Development with HTML 5” Project

So I’m taking the Beginning Game Development with HTML 5 course (or, participating in that study group), and I decided to blog about my project here.

The reason I’ve decided to take this class is to get the game my wife and I are working on, Азбука (Azbuka) back on track. The reason I stopped developing this game is because I got stuck on how to architect the game in a way that would allow rapid addition of logic to the game, since we had a lot of ideas on how to improve it beyond our initial vision.

The game is for pre-schoolers who want to learn the Russian language. It is a combination of starfall.com ABCs, a learning method called Азбука Жукова, and other ideas. At this point, the logic is really simple, although we want to add sever other things eventually. Specifically, we want to add an unhealthy amount of stats for the concerned parent, as well as the supermemo/spaced repetition method for faster, more effective learning.

Right now, the plan is to have a slide (as in slideshow) loop that is within a lesson loop. I am working on a more comprehensive, step-by-step task list.

Showing SQL logging in rails console

After the third time searching how to do this, I figured it’s time to put it up here as a note to self for the next time:


logger = Logger.new(STDOUT)
ActiveRecord::Base.logger = logger
ActiveResource::Base.logger = logger

finding random instances of a model

I find myself doing this somewhat often, so I thought I’d share.

Assuming you have a User model and you want to find a random user:

u = User.find(1 + rand(User.all.count))

Sometimes this returns a RecordNotFound if the user has been deleted; otherwise, it’s a handy code snippet.

Ruby “or” vs. “||” gotcha

In irb:

>> truth = nil or true
=> true
>> truth
=> nil
>> truth = nil || true
=> true
>> truth
=> true

Notes on learning Erlang: Chapter 2

Here are the thoughts/questions I had while reading chapter 2 of the “Erlang Programming” book:

  • Atoms
    • What are atoms most similar to in Ruby, the language I know best? Atoms are like symbols in Ruby, although they’re used differently.
    • Interesting fact: Although atoms can be started with a period (.) which will be ignored, they can’t be started with two or more periods (..). If you really need an atom that starts with multiple periods, just put them in single quotes (‘…………’).
  • What is the difference between and and andalso (analogously, or and orelse)? I would like to see examples where the answer is different between the two uses.
  • in the Erlang console, type shell:module_info(). for info about the Erlang shell module.
Tags: erlang

Notes on learning Erlang

I’ve started to learn Erlang as one of the first tasks at my new job at Snooty Monkey. I am reading the O’Reilly “Erlang Programming” book. Here are some of my notes and questions as I read this book and try it out on my Ubuntu 10.04 system:

  • Installation was fairly straightforward. I downloaded the source from erlang.org. Before starting the install, I ran sudo apt-get build-dep erlang to install necessary erlang dependencies. I followed the install instructions that came in the download; for better readability, I used the github page
  • Some questions I had while reading Chapter 1 of the book:
    • What does the “soft” of “soft real-time systems” mean? Near real-time.
    • What is the run queue? Simple answer here.
  • Chapter 2 forthcoming…
Tags: erlang

First Impressions on NIXTY.com

I was encouraged, if somewhat skeptical, when I read about NIXTY sometime last year. ‘Empowering education for everyone’ sounded too good to be true. Nevertheless, as someone who’s previously wanted to build something similar, I looked forward to this web app existing.

Well, today NIXTY opened up their service for everyone, and I have to admit I’m not disappointed, although I have a few minor usability quibbles (more on those later).

First, a few things I really liked:

  • The idea of empowering education for everyone along with having a substantial free component
  • Clean layout/design in general
  • The ability to mark sections of lessons complete
  • Certificates
  • Very clever how the first course is intro to NIXTY

Here are the quibbles:

  • Use gravatar to automatically select an avatar.
  • Why reinvent the wheel with mail, blog, calendar, contacts? I already have a preferred clients/apps for all of those.
  • In the course directory, gray out all the categories with no classes in them
  • Add a ‘Request Course’ button
  • When I’m taking a lesson, enable ‘full-screen’ layout:
    • hide navigation (leave a toggle link)
    • do a dual-pane view: content on the left, notepad (text area) on the right (configurable). 
  • Add a next/previous navigation at the bottom of each lesson.
  • Marking lesson sections complete should be sent back to the server with AJAX.
  • Display threads inline in the lessons (link should toggle discussion thread with AJAX).
  • In the spirit of outsourcing other non-core functions:
    • use something like disqus for comments
    • let users embed their portfolio or resume from e.g. JobSpice

Overall, I’m cautiously happy with NIXTY and I’ve started taking a course. More posts forthcoming…

Strange error

If you ever get an error like this:

Errno::EAFNOSUPPORT - Address family not supported by protocol - socket(2):

make sure you’re not trying to e.g. access localhost from within the cloud :~)