Skip to content

Instantly share code, notes, and snippets.

04d1b48b6bed24eaa1cf3ac13dc2ac34ae24509f8291857d76b6261692e7d698056f1a4a8db5f432e89132ed139bf8a1afe72b4c210b5dc4263bfc66fac3ce056f
@shellfly
shellfly / emacs.md
Created November 24, 2017 12:56
batch replace in dir in emacs
C-M-h  mark-defun

C-x C-space pop-global-mark

modify-syntax-entry _ w

M-x find-name-dired: you will be prompted for a root directory and a filename pattern.
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 / replace.md
Created September 2, 2017 09:50
replace content in dir on mac

grep -rl {text} app | xargs sed -i"" -e 's/{text}/{replaced_text}/g'

@shellfly
shellfly / rsa.py
Last active February 23, 2016 13:54
RSA算法实现练习
# Rsa Demo
import math
import random
def to_binary(n):
if n / 2 == 0:
return str(n)
return to_binary(n/2) + str(n%2)
assert to_binary(4) == '100'
@shellfly
shellfly / README.mdown
Last active August 29, 2015 14:22 — forked from mtigas/README.mdown
TOTP (Google Authenticator) two-factor auth proof of concept.
@shellfly
shellfly / Django.emacs
Created April 1, 2015 08:53
emacs functions for Django template
(defun goto-template()
"Jump to correspondence Django template file"
(interactive)
(let (tmplName projectDir appName)
(setq projectDir "/home/shellfly/project/src")
(setq tmplName (thing-at-point 'filename))
(setq appName (car (split-string tmplName "/")))
(find-file (concat
(file-name-as-directory projectDir)
(file-name-as-directory appName)
@shellfly
shellfly / tcpdump.md
Created February 2, 2015 17:12
dump http headers

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

@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 / 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 / Vagrantfile
Created September 26, 2014 03:43
speed vagrant network connection
config.vm.provider :virtualbox do |vb|
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end