Skip to content

Instantly share code, notes, and snippets.

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

04d1b48b6bed24eaa1cf3ac13dc2ac34ae24509f8291857d76b6261692e7d698056f1a4a8db5f432e89132ed139bf8a1afe72b4c210b5dc4263bfc66fac3ce056f