Skip to content

Instantly share code, notes, and snippets.

@yaniv-aknin
yaniv-aknin / gist:3957499
Created October 26, 2012 07:49
Check what a process is blocking on using the CLI on Linux

Suppose I have blocking process blocking_process:

import os

os.system('rm -fr /tmp/pipe; mkfifo /tmp/pipe')
print len(open('/tmp/pipe').read())

On Linux, I might check what is it blocking on by doing:

$ strace -p $(pgrep -f blocking_process)

@yaniv-aknin
yaniv-aknin / gist:4701096
Last active December 12, 2015 02:48
Can you think of a better console text colouring library for shell?
#!sh
function newline() { printf "$@\n"; }
function color() {
output="\e[$1m"
shift
[ -n "$1" ] && output="$output$@\e[00m"
printf "$output"
}
function reset() { color "00"; }
@yaniv-aknin
yaniv-aknin / omnidecorator.py
Last active December 12, 2015 04:38
When you read something like this, you go: "yuck!". When you write it, you're totally "dude, I'm so amazing!!1!".
def parse_with(parser):
def decor(func):
def __get__(self, instance, owner=None):
return self.__class__(instance, owner)
def __call__(self, *args, **kwargs):
params = parser.parse_args()
if self.instance:
return func(self.instance, params, *args, **kwargs)
return func(params, *args, **kwargs)
def __init__(self, instance=None, owner=None):
@yaniv-aknin
yaniv-aknin / Procfile
Created February 26, 2013 11:10
compileror: a file compilation service
web: ./compileror $PORT
@yaniv-aknin
yaniv-aknin / app_name.py
Last active December 15, 2015 13:39
This code snippet works fine on my development box (OSX 10.7.5, postgres 9.1.4, Postgres.App 1.0 (11), libpq 0.5.4), works fine from my development box against my Heroku shared database, but breaks with an `(OperationalError) invalid connection option "application_name"` when ran on Heroku. Any explanations?
from os import environ
from sqlalchemy import create_engine
e = create_engine(environ['DATABASE_URL'],
connect_args={"application_name": "foo"})
e.connect()

11 Sep, email from Parallels: Upgrade Notification: Top reasons to upgrade to the new Parallels Desktop 9 for Mac!

19 Sep, email from Parallels: Urgent Service Notification for Parallels Desktop 7 for Mac Users

19 Sep, tweet from me: "Urgent Service Notification for Parallels Desktop 7 for Mac Users". @ParallelsMac, your marketing is disgustingly aggressive. Stop.

19 Sep, tweet from me: @ParallelsMac If my previous message wasn't clear: I doubt I will ever choose to give you money again, ever, just because of your marketing.

19 Sep, tweet from Parallels: @aknin Message received. We want to make sure all our customers are aware, so there are no surprises if they move to Mavericks.

@yaniv-aknin
yaniv-aknin / keybase.md
Created January 20, 2015 16:40
keybase.md

Keybase proof

I hereby claim:

  • I am yaniv-aknin on github.
  • I am yanivaknin (https://keybase.io/yanivaknin) on keybase.
  • I have a public key whose fingerprint is 0793 D8DB D227 5338 920F 5D1A 40D0 78BF 34E4 2A6E

To claim this, I am signing this object:

@yaniv-aknin
yaniv-aknin / gist:7d285f9b1dc2fb91e013
Last active August 29, 2015 14:21
Some thoughts on communications

I posted this internally at Google, someone asked me to post it externally. To be frank, I almost didn't write it because it seemed so obvious. But isn't that the point? What's obvious to you might not be to others. So I'm happy to oblige.

Maybe this is obvious, maybe this is so generic that it's useless, but I feel it has to be written somewhere.

The time you spend on communicating something (writing a doc, an email, a bug, a comment, ...) should be proportional to the "distance" of the person receiving the message.

Distance varies on three axes I can think of:

  • Physical: This one is obvious, but requires some explanation. If someone is far away from you, your bandwidth is hugely limited already. You speak to them less often, they don't get your body language, they don't get your tone, they don't get you. Make things easy for them.
  • Subject matter: The less someone knows about (your project, this topic, your likely state of mind), the more you should explain. Good communication is a lot about empat
@yaniv-aknin
yaniv-aknin / process.py
Created June 26, 2016 10:07
Process UK Land Registry data
#!/usr/local/opt/playground/bin/python
"""
Helper tool to process the UK Land Registry data
https://www.gov.uk/government/publications/land-registry-data/public-data
"""
import numpy
import functools
import multiprocessing
@yaniv-aknin
yaniv-aknin / README.md
Last active April 24, 2021 21:41
Quick tour of FAF (Forged Alliance Forever) historic game data, in the database and the replay files