Elentok's Blog

About me
Linux on the 2012 MacBook Air

Linux on Mac

Last week I tried installing Arch Linux on my 6yo MacBook Air (Mid-2012), to my surprise it went much better than expected :)

Global hotkeys for 8tracks on Mac

A few days ago I started using the 8tracks service, it's a really cool music streaming service.

The only thing I was missing was a global hotkey for play/pause, so I implemented it using a combination of Fluid, AppleScript and Alfred.

ActiveRecord+PostgreSQL mass-insertion benchmarks

In the past couple of weeks I've been researching databases and optimization techniques and I just wanted to share something I discovered.

I'm using:

  • Linux Mint 13
  • PostgreSQL 9.1 (default settings)
  • Ruby 1.9.3p194
  • ActiveRecord 3.2.6
  • an i5 760 with 4GB of RAM

I have an "items" table with 15 columns (5 string, 5 integer, 1 text, 2 date and 2 float) and I'm trying to add 100,000 items to the table.

Writing hebrew text using Vim

Usually when you write hebrew in Vim, you have to write from left to right, which is a little annoying. Vim has two settings that allow typing hebrew easier:

  • set rightleft (or set rl) - display the entire buffer from right to left
  • set keymap=hebrew - changes the keyboard mapping to hebrew (doesn't effect the OS mapping)
How I learned TDD

I first heard about unit tests at an open source developer conference in 2006 and since then I've been trying to understand this concept.

The first tests I wrote were with PyUnit, I don't remember what the project was, I just remember that it was horribly implemented, I didn't have any notion of the SOLID principles, so it was very difficult to write the tests and eventually I gave it up.

A couple of years later I started to develop a large enterprise application in .NET which forced me to improve my software architecture skills, I started reading a lot of books on the subject:

As I was reading the books I began to realize how little I understand about software craftsmanship and how much more there is to learn.

So I started writing tests again (still after the code itself), I could see the value of the tests, since it helped the stability of the application I was working on (to this day there aren't any new bugs).

But the tests still didn't feel right, they didn't cover all of the scenarios, they were annoying to write, I kept having to change the original after adding the tests.

Exporting (hebrew) contacts from a Motorola i876 phone

On Windows:

  • Install iDEN PhoneBook Manager (if you have hebrew contacts, you MUST select "Hebrew" when installing it, otherwise it will mess up your contacts).
  • If you're using the Hebrew interface and it looks like gibberish, you need to go to "Region and Language" in the control panel, and under the "Administrative" tab select "Change system locale" and change it to Hebrew (you'll have to restart).
  • On your phone enter:
    • Main Menu (תפריט ראשי)
    • Settings (הגדרות)
    • Connections (חיבורים)
    • USB
    • Check Data Modem (מודם)
  • Launch the iDEN PhoneBook manager
  • Connect the phone to the computer using the USB cable
  • Select "Load from Phone"
  • It will load the contacts from the phone (the phone will reboot)
  • If you wish you can print the contacts by pressing "Print"
  • Press "Continue"
  • Press "Save to File", it will ask you were to store the mdb file (access database).
Why I love Ruby on Rails

About four months ago I started writing a couple of projects in Ruby on Rails, and the more I used it, the more amazed I was at how easy it was and how fast I was advancing.

The purpose of this post is to share some of the things I love about Ruby on Rails.

How do I ??? with Git?

The purpose of this post is to quickly go over some of the basic things most developers would require from source control software.

I highly recommend reading either Pro Git or Git Community Book.

Undoing a commit

If you committed some code by accident you have the following options:

Undo option #1: Amend

If you just forgot a file or wrote the wrong comment, stage your changes and run git commit --amend. This will merge the new commit with the previous commit (overriding the old comment).

Git Rebase Example

What is rebase?

Rebase means taking commits to made to an older revision of a branch and applying them to a newer revision of that branch (usually when the origin branch has changed while we were commiting).

Rebase is an alternative for merge, it's main advantage over merging is that it allows you to maintain a clean linear history.

Solving Coding Problems

In all of my days as a programmer a lot of people approached me with the question "Why isn't my code working?" and it's usually because of one of the following reasons:

  • Syntax errors - missing semicolons/parenthesis, bad jQuery/css selectors.
  • Not enough knowledge about the problem domain or the technology.

A couple of days ago I was helping a good friend with a coding problem and he told me: "Don't solve it, tell me the strategy to solve it", this was the first time anyone told me that and it got me thinking... he was right, by solving every problem I'm not allowing the young programmers to learn and that gave me the idea to write this post.

I tried to think of the ways I deal with coding problems and I came up with several principles.