Skip to content

Instantly share code, notes, and snippets.

@shellfly
shellfly / py-stack.md
Created September 19, 2012 04:48 — forked from flaneur2020/py-stack.md
notes on django

python的环境与ruby还是有很大不同的,而且框架多如牛毛,将遇到的坑记在这里。

ps: django跟屎一样。 pps: django还不错拉。

virtualenv

直觉上很容易当作virtualenv当作rvm的存在,但实际上python的版本往往并非大问题,更多需要对付的还是三方库。virtualenv其实更多扮演的是Bundler的角色,但在操作上有所不同。

Bundler通过Gemfile列出当前项目需要的gem并将它们安装到系统,在代码中通过Bundler.require(:all)引入gem,并在bundle exec中设置环境变量之类,以选择正确版本的gem。

@shellfly
shellfly / httpserver.md
Last active August 29, 2015 14:05
simple http server with ruby or python

$ ruby -run -e httpd . -p 9090

$ python -m SimpleHTTPServer -p 8000

@shellfly
shellfly / query.md
Last active August 29, 2015 14:05
run query-replace on all files in a directory in Emacs

M-x find-name-dired: RET

Press t to "toggle mark" for all files found.

Press Q for "Query-Replace in Files...": you will be prompted for query/substitution regexps.

Proceed as with query-replace-regexp: SPACE to replace and move to next match, n to skip a match, etc.

@shellfly
shellfly / git.md
Created August 18, 2014 01:56
批量删除git分支
 git branch -D `git for-each-ref --format="%(refname:short)" refs/heads/3.2\*`

把3.2换成要删除分支的前缀, 比如hotfix

@shellfly
shellfly / sed.md
Last active August 29, 2015 14:05
sed usages

打印文件里的指定行

sed -n '10q;6,10p' file

@shellfly
shellfly / nsenter.sh
Created September 25, 2014 08:30
enter a docker namespace
#!/bin/bash
CONTAINER=$1
PID=$(docker inspect $CONTAINER | grep Pid | grep -Eo [0-9]+)
nsenter --target $PID --mount --uts --ipc --net --pid
@shellfly
shellfly / Vagrantfile
Created September 26, 2014 03:43
speed vagrant network connection
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
@shellfly
shellfly / rails.md
Created October 5, 2014 14:53
rails

生成项目

rails new project_name

修改Gemfile source https://ruby.taobao.org

#安装Gems bundle install

生成schema

@shellfly
shellfly / postgres.md
Last active January 1, 2024 00:40
Postgres initialize

Debian 7, Postgres 9.4

安装完后默认生成两个用户,一个系统用户postgres,一个数据库用户postgres,都没有密码,

系统用户postgres不要设置密码,修改数据库用户postgres密码

  1. $ sudo su postgres
  2. $ psql
  3. $ \password
@shellfly
shellfly / tcpdump.md
Created February 2, 2015 17:12
dump http headers

tcpdump -A -vvvv -s 9999 -i eth0 port 80 > /tmp/sample