Skip to content

Instantly share code, notes, and snippets.

View lxneng's full-sized avatar
🎯
Focusing

Eric Luo lxneng

🎯
Focusing
View GitHub Profile
has_virtualenv() {
if [ -e .venv ]; then
workon `cat .venv`
fi
}
venv_cd () {
cd "$@" && has_virtualenv
}
alias cd="venv_cd"
@lxneng
lxneng / gist:1587338
Created January 10, 2012 06:11
delete "^M"
:%s/\r//g
@lxneng
lxneng / gist:1542985
Created December 31, 2011 05:21
AmazonSMTPServer
#!/usr/bin/python
import smtpd
import email
import asyncore
from boto.ses import SESConnection
class AmazonSMTPServer(smtpd.SMTPServer):
amazonSES = SESConnection()
>>> import math
>>> a = (1,1)
>>> b = (1,2)
>>> math.sqrt((b[0] - a[0])**2 + (b[1] - a[1]) ** 2)
1.0
@lxneng
lxneng / gist:1437458
Created December 6, 2011 08:57
Using virtualenv with PyPy
~ mkvirtualenv -p /usr/local/Cellar/pypy/1.6.0/bin/pypy pypy
@lxneng
lxneng / gist:1393018
Created November 25, 2011 07:56
Classes with the same name in different namespaces.

Classes with the same name in different namespaces.

error

sqlalchemy.orm.exc.UnmappedClassError: Class 'lxneng.models.user.User' is not mapped

fix

pip install python_dateutil==1.5
tips
=======
rvm install 1.9.3 --with-gcc=clang
session.query(User).filter_by(id=123).update({"name": u"Bob Marley"})
@lxneng
lxneng / gist:1315190
Created October 26, 2011 02:01
Uninstall Xcode and iPhone SDK

Uninstall Xcode and iPhone SDK

sudo /Developer/Library/uninstall-devtools --mode=all