Moved!
Hi guys - if you're reading this, it's because you're probably following me on tumblr! I moved from tumblr to self-hosted Octopress. You can find me in the usual address at http://blog.amir.rachum.com

Love Begins
RMH
let's talk about Bridgerton tea, my ask is open

pixel skylines

Product Placement
Sweet Seals For You, Always
Game of Thrones Daily
"I'm Dorothy Gale from Kansas"
PUT YOUR BEARD IN MY MOUTH
Mike Driver
YOU ARE THE REASON

★
Keni
ojovivo
Not today Justin
2025 on Tumblr: Trends That Defined the Year

occasionally subtle


seen from United States
seen from Germany
seen from Vietnam

seen from Russia

seen from China

seen from Australia
seen from United States

seen from United Kingdom
seen from Canada

seen from Azerbaijan

seen from South Korea

seen from Australia

seen from Malaysia
seen from United States
seen from United States

seen from Malaysia
seen from Germany

seen from United States
seen from Singapore
seen from Malaysia
@nurdok
Moved!
Hi guys - if you're reading this, it's because you're probably following me on tumblr! I moved from tumblr to self-hosted Octopress. You can find me in the usual address at http://blog.amir.rachum.com

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
I Want to Fix it NOW
I work on Django projects both at work and at home, in the form of side projects (I created HTMLify as a first experiment in full-stack developing and am now working on a minimalistic feed reader).
The other day I got really bummed out at work. At first, I didn't really understand why - I was just depressed. I got talking with a co-worker and he suggested that I introspect and try to pin-point why. After a while of thinking about it, I realized what was wrong. I am embarrassed by the product I'm making.
Python Importing
When you start to work on even rudimentary Python application, the first thing you usually do is import some package you're using. There are many ways to import packages and modules - some are extremely common (found in pretty much every Python file ever written) and some less so. In this post I will cover different ways to import or reload modules, some conventions regarding importing, import loops and some import easter-eggs you can find in Python.
Cheat Sheet
import foo import foo.bar from foo import bar from foo import bar, baz from foo import * from foo import bar as fizz from .foo import bar foo = __import__("foo") reload(foo)
A Pretty Good Work Day
Edit: Emotions were running high when I wrote this and the original blog post that lead to this one. I realize now it was unprofessional to publicly vent like this, so I shelved the original blog post (which was 100% venting) and I edited this post to contain less venting and more constructive. I hope you enjoy it.
Those of you who follow my blog may remember I recently posted about the worst work day of my life. To get you all up to speed, the story is that I work on the backend of a web application and the frontend guys weren't willing to work with our source control (Mercurial) or even operating system (Linux). When we handled the source control for them, they aggressively accused us of ruining their workspace (which we did, by mistake).
Well, I am happy to report that this saga has come to an end. Here's what happened.
Bash Gibberish - Type Less, Do More
Over my several years of experience with bash I found several really useful tips and tricks. This post will deal with some of the more obfuscated looking "variables" that Bash provides.
Comic courtesy of http://themagnificentwhatever.com/
$?: Check the status of the last command
$ hg branch abort: no repository found in '<location>' (.hg not found)! $ echo $? 255 <---- The "hg branch" command failed! $ echo $? 0 <---- The "echo" command succeeded!
!!: Repeat the last command entirely
$ cat secret-file cat: secret-file: Permission denied $ sudo !! sudo cat secret-file DON'T READ THIS FILE!!!
I specifically love to use this with sudo because it looks like you're yelling at your computer and it caves.
!$: Repeat the last parameter of the last command
While this seems more niche and less useful than the previous point, I actually use this the most. It's useful when you want to run two command on the same file, which is very common.
$ mkdir -p /tmp/a/really/complex/path/you/dont/want/to/repeat $ cd !$ cd /tmp/a/really/complex/path/you/dont/want/to/repeat
$$: Get your process id
$ echo $$ 2122 $ ps PID TTY TIME CMD 2122 pts/1 00:00:00 bash 2632 pts/1 00:00:00 ps
Related Posts:
Moving Around with Bash
Making History with Bash
How I Started to Love the Shell

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
The interactive homebrew encryption challenge
There is a wide consensus among security experts that when choosing an encryption algorithm, it’s much better to choose a well-known public algorithm rather than a homebrew one. I completely agree with this approach.
However, I am curious about how easy it is to break a weak, homebrew encryption algorithm. When you’re faced with a seemingly-random piece of data, a bunch of ones and zeros that you have absolutely no context for, and you are only told that it is encrypted with no clue as to how the encryption algorithm works, how would you even know where to start at decrypting it?
To shed some light on this mystery, I’ve decided to do a little experiment here on my blog.
I’m challenging you to break a homebrew encryption algorithm that I’ve written.
Read More
I invite you to my brother's challenge!
Conventions are Arbitrary, So Use This One
Despite the title, my intention is not to start a flame war. I want to discuss docstring conventions in Python, but just as a case study for conventions in general.
I suggested a while ago in my team at work that we should probably agree on docstring conventions. Each of us had different conventions in mind, me included. Instead of just, you know, thinking for myself, I Googled "python docstring conventions" and lo and behold - the first result was PEP 257:
Triple quotes are used even though the string fits on one line. This makes it easy to later expand it.
The closing quotes are on the same line as the opening quotes. This looks better for one-liners.
There's no blank line either before or after the docstring.
The docstring is a phrase ending in a period. It prescribes the function or method's effect as a command ("Do this", "Return that"), not as a description; e.g. don't write "Returns the pathname ...".
The one-line docstring should NOT be a "signature" reiterating the function/method parameters (which can be obtained by introspection).
[...]
And it goes on. Now, you may agree with some of these items and disagree with other (personally - the "phrase as a command" I love; the "put a blank line before the ending quotes", not so much), but I think the value of this document is that it simply exists and is agreed upon. Caring about how many spaces to put before a curly brace is a phase. It's one of the steps of teaching yourself how to program:
Get involved in a language standardization effort. It could be the ANSI C++ committee, or it could be deciding if your local coding style will have 2 or 4 space indentation levels. Either way, you learn about what other people like in a language, how deeply they feel so, and perhaps even a little about why they feel so.
Have the good sense to get off the language standardization effort as quickly as possible.
However, caring about which standardization to use is wholly different from caring about whether you're complying with any. Standards are arbitrary, yes, but they're important. I think PEP 257 is great. Not because they get the spacing right, but because it's important to have an agreed upon document (signed by the BDFL - a bonus) that does just this. So when I review other people's code, I correct them and I refer them to this PEP. If they complain I say "I don't care where we put our spaces, but we should be consistent. Somebody already did the work of putting a document together, so why not use it?".
Django QuerySets: Fucking Awesome? Yes
Django QuerySets are pretty awesome.
In this post I'll explain a bit about what they are and how they work (if you're already familiar with them, you can jump to the second part), I'll argue that you should always return a QuerySet object if it's possible and I'll talk about how to do just that.
Python: Common Newbie Mistakes, Part 2
Scoping
The focus of this part is an area of problems where scoping in Python is misunderstood. Usually, when we have global variables (okay, I'll say it because I have to - global variables are bad), Python understands it if we access them within a function:
bar = 42 def foo(): print bar
Here we're using, inside foo, a global variable called bar and it works as expected:
>>> foo() 42
This is pretty cool. Usually we'll use this feature for constants that we want to use throughout the code. It also works if we use some function on a global like so:
bar = [42] def foo(): bar.append(0) foo() >>> print bar [42, 0]
But what if we want to change bar?
Python: Common Newbie Mistakes, Part 1
In the past few months I've been helping some people who are new to Python to get to know the language. I found that there are some pitfalls that almost everyone meet when they're new to the language, so I decided to share my advice with you. Each part of this series will focus on a different common mistake, describe what causes it and offer a solution.

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
Python: hash, id and Dictionary Order
TL;DR - really, seriously, no kidding, don't even think about relying on dictionary traverse order, because it may change even from seemingly unrelated code changes.
Today I ran into one of the most bizarre behaviors in Python I've ever seen. A co-worker was debugging some code and called me to help. There was a class that polled a few database tables for specific entries and for some reason, it failed to find them (although they existed). So, we added a breakpoint with pdb:
import pdb pdb.set_trace()
While we were debugging the code, it seemed to work. Huh, we thought to ourselves, let's remove the pdb statement and see if it works now. It didn't. Our program only worked with the pdb statement.
A Case for a OneToMany Relationship in Django
There are three types of model relationships that Django provides: many-to-one, many-to-many and one-to-one. In the following post I intend to make a case for adding a one-to-many relationship to this list.
Obviously, the immediate opposition to this proposal is that all relationships in Django are provided in a two-way manner (via related_name), so there's no need for it. Let's take a look at two reasons why I think this new relationship is called for.
You're a computer geek, right? Can you help me with something?
My Worst Nightmare
Eclipse's Background Indexer: I Hate You
Today at work I had to format my VM drive (so I could extend the partition to an amazing 40GB). That's where all my code, and my Eclipse workspace is stored. Regarding the code, it was quite easy - go through all my Mercurial repos, commit everything (on a feature branch, of course), push, and delete the repo. The Eclipse workspace can't be handled so easily, so I backed it up, formatted my hard drive and restored it. I recloned my Mercurial repos and I was ready to go. However, from the moment I opened Eclipse back on, it was slow. I'm not talking about your regular bloated-IDE slow-- I'm talking full-blown window-barely-responding-to-my-clicking-and-typing feeling-like-Helen-Keller hell. That's... you know... quite a big part of programming. So I spent the better part of my day searching online for solutions, like replacing my JVM; switching workspaces and configuring everything from scratch; disabling and enabling different plugins; deleting Eclipse's metadata, etc.
It was only then that I saw it. That haunting, terrible little message at the bottom-right corner of my screen. Indexing (C++) 0%. Well, I know the title was a spoiler, but here goes: Eclipse's background indexer sucks. You know what, Eclipse? It's fine that you need to index my code. I get it. But let's face it - if I find myself not being able to work on account of a "background" process, it's not really working in the background, is it now? Just admit you can't do it and let me either wait, knowingly, for you to finish, or cancel the indexing all together. Better yet, let me "snooze" the indexing to a later time (say, when I'm home).
While we're on the subject of Eclipse's "background" activities, I think it's time to say - pressing Ctrl+B by accident is one of the worst things that happen to me during the day. It sets up a "building project" window that simply ignores any attempts by me to cancel it. I'm working on a big project and I don't use Eclipse to build it, but Eclipse's default builder doesn't take no for an answer. And yeah, I know - I can rebind the key for the build - but I do need it for other projects. It's find that the build message come up - but why can't I cancel it like expected? Why does it take 2-3 minutes for it to respond to my request?
Okay, okay. I vented a little and I feel better now. You're not mad, Eclipse... right? You know good couples fight from time to time?
I'm so sleeping on the couch tonight.
Notification Etiquette
On a Thursday, a couple weeks ago, I wanted to ask a friend if he wanted to meet with me on Friday morning. It was about a quarter past midnight and I was on the horns of a dillema. How should I contact him?
A phone call is out of the question, of course - you can't call someone that late. But what about an SMS? I think that the etiquette for SMS messages are also quite established as waking-hours only. So my instinct was to message him on Facebook; but I know he has a smartphone. If I send him a Facebook message, it'll make a sound and it might wake him up. Pretty much every means I have to contact someone creates a sound or another interruption on their end. Notifications are great, but when you live in a world where every interaction is online and instant, how do you uninterruptedly contact someone?
When I attended the Technion, I once navigated into a former TA's personal website, and the how to contact me page really hit a chord with me:
Call me weirdo if you like, but I don't like phones. I think that phones with incoming calls are the worst invention ever made. The reason is simple; when you have a phone, you lose control of your own time schedule. Just about anyone can interrupt whatever it is that you're doing, whenever they want. In other words, if you like it or not, other people control you. Take a minute, give it a little thought.
So, there is no way to reach me by phone.
I really like that thought.
We are essentially talking about a fight between synchronous and asynchronous communication. In the past, the line was simple. A phone call or a personal meeting would be synchronous. A text or an email (or god forbid, snail mail) would be asynchronous. Today, it's mostly a grey area. It's not only technology, it's culture. Texts are to be answered immediately. Whatsapp groups are like chat rooms and less like a slow-response method of communicating. Facebook went ahead and ruined our social life with their seen feature. My option of saying I didn't catch someone message is now gone. Synchronous communication won, and I'm rooting for the losing team.
Can we still do something about this? How would you respond to a middle-of-the-night Facebook/Whatsapp/SMS message? What's your notification etiquette?

Anya is live and ready to show you everything. Watch her strip, dance, and perform exclusive shows just for you. Interact in real-time and make your fantasies come true.
Free to watch • No registration required • HD streaming
My First Web Project is Out
I’m happy to announce that I Got Something Done (patent pending) and that a few days ago I released my first web project, HTMLify, into the world. HTMLify is quite a simple one-page web tool that lets programmers take code snippets and generate HTML segments to paste on their blog, maintaining whitespaces, escaping special HTML characters, etc.
As I stated in HTMLify’s footer, I created this project mainly for educational purposes. Firstly, I wanted to create this as a “full stack” developer, meaning I wanted to code everything - from the request processing backend to the color of each button. It was tough at times. Backend is where I naturally see myself, as a Python programmer, and doing HTML/CSS stuff is not my forte. I threw in some AJAX into the mix to make things a little bit more interesting. Secondly, I wanted to not only experiment with different technologies; I wanted to finish stuff completely. It’s so easy to pick up an editor, try out some HTML, make a table or two and say you’ve got some experience, but it’s not until you work hard to tie up all the loose ends, that you get to know what it’s really like. I can also feel proud to show this off to you people and get some feedback, which would be pointless to do for a half-assed project.
What did I learn from this experience?
You should start thinking about mobile-compatibility as soon as possible. I didn’t and it was a bit of a pain. Not too much, but I only had one page, so I can only imagine what it’s like on a much bigger site.
I don’t like doing front-end stuff, but at least now I feel pretty comfortable with the fact that I could help out if needed, or if I don’t get good support from guys working on it.
UI kits are pretty cool. I think I have a good grasp on UX (I hope) and how I’d like the final layout to look like, but if I had to design every button… it’d look like a 12 year old girl’s myspace page.
I have never deployed a web application before. I'm using heroku for this one and it's a breeze! Deploying via git push is such a great idea as it incorporated additional functionality into already acquired knowledge.
Showing your new project to HN really brings a ton of people to see your project and you can get a whole lot of feedback for it.
All in all, I had a really good time and I'm already thinking about my next project...
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 AM) (Detached) 1 Socket in /var/run/screen/S-rachum. $ screen -r 6786.pts-0.ubuntu
... And that's all you need to know to get something out of screen.