This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ctrl-z | |
bg | |
touch /tmp/stdout | |
touch /tmp/stderr | |
gdb -p $! | |
# In GDB | |
p dup2(open("/tmp/stdout", 1), 1) | |
p dup2(open("/tmp/stderr", 1), 2) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;;;;;;;;; | |
;; erc ;; | |
;;;;;;;;; | |
; http://www.emacswiki.org/emacs/ErcHighlightNicknames | |
(and | |
(require 'erc-highlight-nicknames) | |
(add-to-list 'erc-modules 'highlight-nicknames) | |
(erc-update-modules)) | |
;;; map ctrl-a to beginning of line |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
http://stackoverflow.com/questions/598672/git-how-to-squash-the-first-two-commits | |
# Go back to the last commit that we want to form the initial commit (detach HEAD) | |
git checkout <sha1_for_B> | |
# reset the branch pointer to the initial commit, | |
# but leaving the index and working tree intact. | |
git reset --soft <sha1_for_A> | |
# amend the initial tree using the tree from 'B' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## delay sourcing venv to workon call | |
## replace "source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper.sh" | |
## with below block | |
function load_env { | |
if [ type -p workon &> /dev/null ]; then | |
# nothing, source is loaded | |
workon "$@" | |
else | |
unalias workon | |
source /Library/Frameworks/Python.framework/Versions/2.6/bin/virtualenvwrapper.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var partial = exports.partial = function partial(fn) { | |
var args = arguments, | |
func = fn; | |
[].shift.apply(args); | |
return function() { | |
var _args = [].slice.call(args, 0); | |
[].push.apply(_args, arguments); | |
return func.apply(func, _args); | |
}; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
""" | |
Add php-serve.py to your PATH, then, from whatever directory is the root | |
of your PHP application, just run: | |
$ php-serve.py | |
You can optionally specify a port number as an argument. By default, | |
port 8000 is used: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def charorquoted(strn): | |
c = anychar(strn) | |
if c[0] == '"': | |
return None | |
elif c[0] == '\\': | |
c2 = anychar(c[1]) | |
if c2[0] in ('\\', '"'): | |
return (c[0] + c2[0], c2[1]) | |
else: | |
return c |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Monads in Python, as close as I can get them to | |
Haskell | |
""" | |
class Monad(object): | |
def return_(self, value): | |
raise NotImplementedError() | |
def __ge__(self, mf): | |
raise NotImplementedError() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" A script to attempt the compression of written english | |
to the chinese character set """ | |
import os | |
from collections import OrderedDict | |
from math import log | |
import itertools | |
from collections import Counter | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var raw_str_regex = "-([a-zA-Z0-9_]+)$"; | |
var regex = new RegExp(raw_str_regex, "gm"); | |
var lst = [ | |
"this is -not", | |
"this is -not", | |
"this is -not", | |
"this is -not", | |
"this is -not", | |
"this is -not" |