May 2013
2 posts
Using 'screen' - The Absolute Essentials
You’re probably here because you heard screen is a more “safe” way to ssh, so that a broken connection won’t terminate your processes. Here’s how to do it: Installation sudo apt-get install screen Initial connection $ ssh rachum@server $ screen Reconnection $ ssh rachum@server $ screen -ls There is a screen on: 6786.pts-0.ubuntu (05/10/2013 09:42:11...
May 10th
2 notes
My Licensing Wake-Up Call
The other day I got an email that really hit me on the head. It was titled “JOOLS, Y U NO SPECIFY A LICENSE?” and here’s how it read: FYI, your Jools project on GitHub specifies no license.  It looks like you intend it to be Open Source or Public Domain, but without specifying a license explicitly, the license is “all rights reserved, no reuse or redistribution...
May 9th
1 note
April 2013
1 post
Python: Number Conversion Chart
Ever forget how to take a hex string like “2D” and convert it into binary data? Or how to parse an ascii-binary string like “101101” into a plain integer? Me too. That’s why I crafted this table. It doens’t include all conversion, but it includes every conversion type I know, and you can chain them to get from any source type to any destination. Every from/to...
Apr 20th
7 notes
January 2013
3 posts
3 tags
Making History with Bash
This is a nifty little trick for making Bash a little more intuitive (for my taste). Usually, when you press the up key, Bash will bring back the last command you typed. This is cool, but what bothers me is that sometimes I start typing a command and then remember I executed it before. So I press the up key and… Bash shows me the last command, disregarding what I typed. What I want it to do...
Jan 15th
3 notes
2 tags
Moving Around with Bash
Little things matter. I’m often amazed of how I can feel I mastered a certain tool or technology, only to discover I’ve missed some basic way of using it. It happened to me on Windows a couple of weeks ago when I discovered cool keyboard shortcuts, like Win+E (which opens My Computer), or on Eclipse when I found out there is a menu that finds everything. On Linux, I’ve found that...
Jan 5th
3 notes
1 tag
Python: The Dictionary Playbook
I so often come across various kinds of boilerplate code regarding dictionaries in Python, that I decided to show some of it here and share the more concise way of performing the same operations. Presenting: The Dictionary Playbook. [[MORE]] 1. The “Are You There?” This one is pretty simple, but I’m amazed as to how it’s missed - finding out if a key exists in the...
Jan 2nd
29 notes
December 2012
1 post
2 tags
Moving Changes to Feature Branches After-the-Fact...
At my workplace we use Mercurial. We don’t usually work in feature-branches, but in the default branch instead. This is usually not problematic, but I keep running into the following situation: I started working on feature A (on the default branch), when suddenly I am forced to work on (and ship) feature B instead, for whatever reason. When that happens, I usually say to myself “God...
Dec 29th
1 note
November 2012
1 post
1 tag
Eclipse Quick Access - How Did I Miss this?
I can’t believe I’ve been using Eclipse for - what? - 4 or 5 years now without using Quick Access. Sidebar - I’ve long been promoting Eclipse’s excellent menu search. It lets you search menu windows for each and every preference and value. For example, consider looking for how to enable print margin display (for keeping your code from exceeding 80 character rows; you do...
Nov 2nd
September 2012
2 posts
Is it possible to be productive with only a...
In the last month, I was in several situations where I was bored to death and had only my Android phone for amusement (Samsung Galaxy S2, for those wondering). I have the itch to program or do something productive in these situations, but for the life of me, I can’t think of any such option and I usually end up playing a brain-numbing game instead. I am catching up on some reading in...
Sep 11th
1 note
Programming in The Zone
A lot has been written about the concept of flow, and I was well aware of this particular psychological mode way before I had a name for it. I like saying that I’m in the zone. In The Social Network, they refer to this state as being wired in. The most interesting thing about the zone is, of course, how to get there. I can’t really pinpoint the variables that help me get in the flow...
Sep 8th
August 2012
4 posts
4 tags
Reddit Thinks I'm a Spammer
When I published my post about else statements in Python, I got lots of comments and a score of over 400 on reddit.com/r/programming (okay, I realize I’m “bragging” again, but this actually is a part of the story). My several following posts got measly viewership although I posted them on reddit as well. I was surprised to discover they weren’t showing up on the New page at...
Aug 25th
1 note
1 tag
You Can't Handle the Truth!
I got a chance to review some other people’s Python code recently, and there’s one comment I almost always have to give, which is: if x and if x is not None are not the same! corollary: if not x and if x is None are also quite different, obviously. This usually happens when someone assigns None to a variable (say, x) as a sentinel value, and then x may or may not be assigned to....
Aug 25th
5 tags
Gathering the Comments of the Web
My recent post about the else keyword in Python was a tremendous success (relative to my other posts), reaching 20,000+ unique visitors within about 24 hours. It was especially successful in Reddit’s /r/programming, where it got over 400 total upvotes and 130 comments. However, in the post’s own Disqus thread, there were only 3 comments (one of them was mine). Now, I get that people...
Aug 6th
1 tag
Self Printing Programs in Python
Let’s talk about self printing programs (or, quines). A self printing program is, as is its name, self explanatory. Today I thought about how to implement a quine in Python, I whipped up a solution on my own and then posed the challenge to some people in the office. These are the results: My Version  s = r"print 's = r\"{0}\"'.format(s), '\n', s" print 's = r\"{0}\"'.format(s), '\n', s ...
Aug 5th
July 2012
7 posts
TDGotchi - A Tamagotchi that lives in your Eclipse... →
Jul 24th
1 tag
What else is there in Python?
We all use the else keyword in Python, usually accompanying if statement: if x > 0:     print 'positive' elif x < 0:     print 'negative' else:     print 'zero'  but Python has a few other uses to the else keyword that most people are unfamiliar with. [[MORE]] for .. else I bet you didn’t know that you can put an else clause after a for loop! What does it do? When the items you...
Jul 23rd
12 notes
3 tags
Cool Syntax and Weird Documentation - Fun with...
I was looking for a way to parse TCP/IP packets in Python, when a friend recommended Scapy. Scapy is a nice python package that’s got a very cool interface using the “div” operator, and is used like so: packet = IP()/TCP()/"GET / HTTP/1.0\r\n\r\n" str(packet) # returns the packet's binary data  which is pretty cool and creative. It makes the layers concept pretty visual. Now, I...
Jul 18th
Converting a Software Thief into a Customer →
Jul 17th
3 tags
A Late Introduction to Jools
A while back I wrote a small Java tools library called Jools. I never really presented it to “the world” (except for hosting it on Github). So I figured, now is my chance. Here are the features Jools provide: Python-like Range Objects This one is pretty straight forward for (final int i : new Range(5)) {     players.add(new SmartPlayer(names.get(i))); } Generating...
Jul 14th
1 tag
Double Iteration in List Comprehension
Here’s something I didn’t know possible in Python: iteration over more than one iterable in a list comprehension: >>> seq_x = [1, 2, 3, 4] >>> seq_y = 'abc' >>> [(x,y) for x in seq_x for y in seq_y] [(1, 'a'),  (1, 'b'), (1, 'c'), (2, 'a'), (2, 'b'), (2, 'c'), (3, 'a'), (3, 'b'), (3, 'c'), (4, 'a'), (4, 'b'), (4, 'c')] Cool, isn’t it? It’s...
Jul 13th
2 tags
An Unsearchable Problem (Meta Googling)
I love Google Chrome. The attention to details in Chrome’s UI is no less than genius. Its tab-closing behavior is one of my favorites. That’s why little kinks it has really bother me. I usually have no issues with Chrome at all, but there’s a feature I came across recently that’s really bugging me.  Sometimes I want to search for Google products online. Google’s...
Jul 12th
June 2012
2 posts
1 tag
Yet Another Sign Up
A friend recommended Pocket today. Tried to sign up, got this screen: As I was filling in my details, I felt a strange feeling. Something is wrong. According to Wikipedia: As of December 2009, there are over 1 billion OpenID enabled accounts on the Internet (see below) and approximately 9 million sites have integrated OpenID consumer support. Guys, these are statistics from 3 years ago. How...
Jun 26th
1 note
1 tag
Moving up the Android Ladder
I have a Samsung Galaxy S2 which used to run CyanogenMod 7.1, until a few days ago, I encountered some issues. So, I decided to live on the edge and install the nightly version of CyanogenMod 9. Yep, not even a release candidate when I installed it (there is now). That’s just how I roll. Well, instead of doing some in-depth review or talking about the future of the Android platform,...
Jun 26th
May 2012
4 posts
1 tag
FOSS Developers: Make Your Products Easy to Build
(FOSS: Free Open Source Software) I recently started to use Eclipse Color Themes at my home desktop. ECT is an Eclipse plugin which allows you to, well, easily choose and manage color themes (which is a feature that Eclipse strangely doesn’t offer). I downloaded it via the Eclipse Marketplace (everything is a market these days, isn’t it?) and it worked pretty smoothly. I wanted to use...
May 27th
1 tag
Damn You, Microsoft Word. Damn You.
I hate Microsoft bashing. I really do, but I’m on the verge of breaking my desktop apart with a baseball bat. Well, except that’s too much of a cliché. And we don’t play baseball in Israel. And I would probably hurt myself more than my computer. But still. Very annoyed. Here’s the deal: I’m writing a document in Microsoft Word* and I’m basically just gathering...
May 20th
3 tags
How I Started to Love the Shell and Why PowerShell...
I’ve been using Windows 7 for a couple of years now and only recently I found PowerShell. If I didn’t hear about it, maybe you haven’t either, and I would love to correct that. But first, an obligatory story. On my second semester in the university, I took a course called “Introduction to Systems Programming”. It’s a course where you learn advanced C and then...
May 17th
1 note
2 tags
Learning to Use Mercurial
This post is going to be brief. I’ve been reading about Mercurial, since we are soon going to use it at my workplace. I just popped here to recommend Joel Spolsky’s great Mercurial tutorial. It’s written really well, in par with Joel’s usual stuff, very funny and educational. See that? She’s still working with Tortilla chips. Tortilla chips!
May 7th
April 2012
10 posts
2 tags
One Line Tree Implementation in Python →
This is pretty cool.
Apr 26th
2 tags
Implementing the Singleton Pattern in Python
TL;DR: Use metaclasses - see #4 on the list I recently heard some people at work talking about ways to implement the Singleton pattern in Python. I’m fairly new to Python, and for me, the most elegant Singleton definition would be in Java: enum MySingleton {     INSTANCE;     // methods, members, etc. } and that’s it! Use MySingleton.INSTANCE and you got yourself a singleton....
Apr 26th
2 tags
Tag, You're It!
A few years ago, I was a real proponent of Google Desktop. I used it every time I wanted to open a file on my computer. Just hit Ctrl-Ctrl, type in something and get immidiate results. For some reason, however, I noticed that time after time, Google Desktop stopped providing me with good results. I don’t know what happened, but a lot of times it just didn’t find the files I wanted. I...
Apr 23rd
3 tags
I Hate It When My Tests Pass
I’ve been writing a bunch of unit tests recently, and I came across an odd behavior. I was writing the tests for existing code and whenever I would write a test, as soon as it passed, I wouldn’t trust it. Nothing ever works the first time around. It simply can’t be. So I found myself repeating quite an odd ritual: Write a test. Run it. It passed. There’s no way that...
Apr 22nd
1 tag
Valve's New Employee Handbook →
This is, by far, one of the coolest things I have ever read.
Apr 21st
2 tags
Getting Something Done
I read stories from Hacker News every day, I’m subscribed to Jeff Atwood’s excellent Coding Horror, I check out people’s profiles at StackOverflow and wherever I see someone’s About Page it always says “Hi! I’m X, the creator of Y”. There’s always a public product they’ve developed that they can talk about. I want that for myself. I...
Apr 20th
3 tags
Let Your Process Go
In my previous work place, we were using ClearCase for source control. We were programming in a Unix environment and we we’re using cleartool for our ClearCase needs. We didn’t use a workflow control tool or anything. Code reviews were mandatory, but it wasn’t enforced by a higher power. The team was self-governed in this respect. Code reviews were conducted 99% of the time. It...
Apr 16th
2 tags
Refactor for Equal Levels of Abstraction
Refactoring is great. I’m all for coding some tests and refactoring code one small step at a time until it’s perfect. However, sometimes it’s difficult to know when to stop. For example, consider the following snippet: class Foo(object):     ...     def foo(self, config_file, raw_data, output_path):         self.set_config_data(config_file) ...
Apr 14th
3 tags
Testing is not a Feature
I pointed out to someone at work today that PyDev 2.5.0 now offers really cool TDD support. I’m not a huge TDD proponent or anything, but this stirred up a discussion. This guy, let’s call him John, said that “TDD may shorten the time it takes to develop a feature, but sometimes a feature is so urgent we may want to deliver it as quickly as possible and test it later”....
Apr 12th
3 tags
Setting Up LyX with Hebrew Support
Introduction So you want to use Hebrew with LyX under Windows. Pfffh! A lot of articles, tutorials, support groups and suicide letters are out there on the web for the sole purpose - writing Hebrew in LyX just right. And not only that, but using English when needed as well, without completely screwing up your paper. After having gone through most of them, more or less (including a few months in...
Apr 12th