Skip to content

Instantly share code, notes, and snippets.

@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 / sed.md
Last active August 29, 2015 14:05
sed usages

打印文件里的指定行

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

@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 / 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 / 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 / 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。