As configured in my dotfiles.
start new:
tmux
start new with session name:
| # use mixin | |
| class SingletonMixin(object): | |
| _instance = None | |
| def __new__(cls, *args, **kwargs): | |
| if not cls._instance: | |
| cls._instance = super(SingletonMixin, cls).__new__(cls, *args, **kwargs) | |
| elif hasattr(cls, '__init__'): | |
| del cls.__init__ |
| class RestfulApi(Api): | |
| def __init__(self, *args, **kwargs): | |
| self.ignore_errors = kwargs.pop('ignore_errors', []) | |
| super(RestfulApi, self).__init__(*args, **kwargs) | |
| def error_router(self, original_handler, e): | |
| for ignore_error in self.ignore_errors: | |
| if isinstance(e, ignore_error): | |
| return original_handler(e) |
| # -*- coding: utf-8 -*- | |
| from app.libs.store import store | |
| user_relations = store.Table('user_relations', | |
| store.Column('source_id', store.Integer, store.ForeignKey('users.id')), | |
| store.Column('target_id', store.Integer, store.ForeignKey('users.id'))) | |
As configured in my dotfiles.
start new:
tmux
start new with session name:
| git --first-parent log | |
| git --no-merges log |
| function sw { svn sw "^/branches/$USER/$1" ;} | |
| function co { svn copy "^/trunk" "^/branches/$USER/$1" ;} | |
| function sl { svn ls "^/branches/$USER" ;} | |
| function swt { svn sw "^/trunk" ;} | |
| function stq { svn st -q ;} | |
| function si { svn info ;} | |
| function su { svn up ;} | |
| function sd { svn diff | colordiff | less -R ;} | |
| function st { svn st;} |
| # Enable proxy setting from terminal in ubuntu 12.04 | |
| function myProxyOn() { | |
| gsettings set org.gnome.system.proxy mode 'manual' # ' manual / nome / automatic ' | |
| gsettings set org.gnome.system.proxy.http host '10.8.0.1' | |
| gsettings set org.gnome.system.proxy.http port 8118 | |
| gsettings set org.gnome.system.proxy.https host '10.8.0.1' | |
| gsettings set org.gnome.system.proxy.https port 8118 | |
| gsettings set org.gnome.system.proxy.ftp host '10.8.0.1' | |
| gsettings set org.gnome.system.proxy.ftp port 8118 |
Prereq:
apt-get install zsh
apt-get install git-coreGetting zsh to work in ubuntu is weird, since sh does not understand the source command. So, you do this to install zsh
wget https://github.com/robbyrussell/oh-my-zsh/raw/master/tools/install.sh -O - | zsh
| def setup_stub_mc(): | |
| class StubClient(object): | |
| def __getattr__(self, key): | |
| def _(*args, **kwargs): | |
| return None | |
| return _ | |
| _mc.cache_mc.mc = StubClient() |
| from contextlib import contextmanager | |
| class ObjectWrapper(object): | |
| def __init__(self, wrapped_object): | |
| self.wrapped_object = wrapped_object | |
| def __getattr__(self, attr): | |
| return self.wrapped_object.__getattribute__(attr) | |
| @contextmanager |