This file contains hidden or 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
| normpath(Path) -> | |
| filename:join(normpath(filename:split(Path), [])). | |
| normpath([], Acc) -> | |
| lists:reverse(Acc); | |
| normpath([".." | Rest], [Prev|Acc]) -> | |
| normpath(Rest, Acc); | |
| normpath([Head|Rest], Acc) -> | |
| normpath(Rest, [Head|Acc]). | |
| -ifdef(TEST). |
This file contains hidden or 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 hidden or 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
| #!/bin/bash | |
| # | |
| # Usage: bulkreplace <path> <filetype> <find_pattern> <replace> | |
| function infile(){ | |
| find $1 -name "*$2" -exec grep -H "$3" {} \; | sed 's/:.*//'; | |
| } | |
| for f in $(infile $1 $2 $3); do replace "$3" "$4" -- $f; done |
This file contains hidden or 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 | |
| import random | |
| import string | |
| def random_pw(): | |
| char_set = list(string.letters + string.letters.upper() + string.digits + string.punctuation) | |
| return ''.join(random.sample(char_set, 20)) |
This file contains hidden or 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
| from django import template | |
| tpl = template.Template(""" | |
| {% block head %}{% endblock %} | |
| {% block body %} | |
| {% block content %}{% endblock %} | |
| {% endblock %} | |
| """) | |
| def getnode(node, name = 'content'): |
This file contains hidden or 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
| #!/bin/bash | |
| # Choose one | |
| complete -W "$(grep -E '^[0-9]' /etc/hosts | awk '{ print $2 }')" ssh scp rsync ping | |
| complete -W "$(grep -E '^ssh' ~/.bash_history | awk '{ print $2 }')" ssh scp rsync | |
| complete -W "$(grep -E '^(\w)' ~/.ssh/known_hosts | awk '{ print $1 }' | sort -u | cut -d ',' -f 1)" ssh scp rsync ping |
This file contains hidden or 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
| css = """ | |
| div.Bk { | |
| font-family: DejaVu Sans Mono, Courier, Monospace !important; | |
| } | |
| textarea { | |
| font-family: DejaVu Sans Mono, Courier, Monospace !important; | |
| } | |
| td > div { | |
| font-family: DejaVu Sans Mono, Courier, Monospace !important; | |
| } |
This file contains hidden or 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
| """ | |
| jQuery templates use constructs like: | |
| {{if condition}} print something{{/if}} | |
| This, of course, completely screws up Django templates, | |
| because Django thinks {{ and }} mean something. | |
| Wrap {% verbatim %} and {% endverbatim %} around those | |
| blocks of jQuery templates and this will try its best |
This file contains hidden or 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
| # Defaults that we'll need | |
| include_recipe "apt" | |
| package "vim" | |
| package "screen" | |
| package "git-core" | |
| package "mercurial" | |
| package "subversion" | |
| package "python" |
This file contains hidden or 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
| ;; add this to your ~/.emacs or ~/.emacs.d/init.el file | |
| ;; jump parens | |
| (defun match-paren (arg) | |
| (interactive "p") | |
| (cond | |
| ((looking-at "\\s\(") (forward-list 1) (backward-char 1)) | |
| ((looking-at "\\s\)") (forward-char 1) (backward-list 1)) | |
| ((looking-at "\\s\{") (forward-list 1) (backward-char 1)) | |
| ((looking-at "\\s\}") (forward-char 1) (backward-list 1)) |