Skip to content

Instantly share code, notes, and snippets.

/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/LaunchServices.framework/Versions/A/Support/lsregister -kill -r -domain local -domain system -domain user && killall Finder
#! /usr/bin/env python
#coding=utf-8
#----config part----
INIT_CMDS = ["iptables -F",#clean all
"iptables -X",
"iptables -t nat -F",
"iptables -t nat -X",
"iptables -P INPUT DROP",#forbid all
"iptables -A INPUT -i lo -j ACCEPT"#accept all localhost
/* Gmail style scrollbar */
::-webkit-scrollbar {
width: 12px
}
::-webkit-scrollbar-thumb {
border-width: 1px 1px 1px 2px
}
::-webkit-scrollbar-track {
border-width: 0
}

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@etng
etng / master.vim
Created February 14, 2014 05:58 — forked from gmccreight/master.vim
" copy all this into a vim buffer, save it, then...
" source the file by typing :so %
" Now the vim buffer acts like a specialized application for mastering vim
" There are two queues, Study and Known. Depending how confident you feel
" about the item you are currently learning, you can move it down several
" positions, all the way to the end of the Study queue, or to the Known
" queue.
" type ,, (that's comma comma)
@etng
etng / init_django_project.sh
Created February 28, 2014 04:21
Init a django project
pip install virtualenvwrapper
source /usr/local/bin/virtualenvwrapper.sh
cat >> ~/.bashrc << “END”
export WORKON_HOME=$HOME/.virtualenvs
source /usr/local/bin/virtualenvwrapper.sh
END
mkvirtualenv myenv
workon myenv
@etng
etng / forms.py
Created February 28, 2014 06:04 — forked from maraujop/forms.py
# -*- coding: utf-8 -*-
from django import forms
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Layout, Div, Submit, HTML, Button, Row, Field
from crispy_forms.bootstrap import AppendedText, PrependedText, FormActions
class MessageForm(forms.Form):
text_input = forms.CharField()
@etng
etng / weighted_random_choice.py
Created March 6, 2014 02:44
use bisect to random get items with weighted probability, the weight field can be specified
import random
import collections
import bisect
def weighted_random_choice(candidates, field='weight'):
'''
use bisect to random get items with weighted probability, the weight field can be specified
'''
prepared_candidates = {}
total_weight = 0
@etng
etng / gist:9408675
Created March 7, 2014 09:52
clear django cache
export DJANGO_SETTINGS_MODULE='my_project.settings'
cd my_project/
python manage.py shell
from django.core.cache import cache
cache.clear()
@etng
etng / .screenrc
Created April 24, 2014 07:01
Screen RC file for screen file
hardstatus on
hardstatus alwayslastline
hardstatus string "%{.bW}%-w%{.rY}%n %t%{-}%+w %=%{..G} %H(%l) %{..Y} %Y/%m/%d %c:%s "