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
| 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
| #!/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
| #!/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
| """ 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
| 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
| abspath(Path)-> | |
| Bits = filename:split(Path), | |
| Folder = fun(Elem, Acc)-> | |
| case Elem of | |
| ".." -> | |
| [ lists:nth(Seq, Acc) || Seq <- lists:seq(1, length(Acc)), Seq < length(Acc) ]; | |
| _ -> | |
| Acc ++ [Elem] | |
| end |
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
| ~ $ python | |
| >>> import os | |
| >>> os.path.abspath("../foo") | |
| '/home/foo' | |
| ~ $ erl | |
| 1> filename:absname("../foo"). | |
| "/home/alen/../foo" |
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
| ;; Because my musclememory is used to :wq - don't shoot me | |
| (global-unset-key "\M-:") | |
| (global-set-key "\M-:wq" 'save-buffers-kill-terminal) |
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
| # Tests performed on a Linode 512 instance. | |
| # Keep in mind that Nginx is writing logs and Spooky is not. | |
| # Kudos definitely go to http://twitter.com/ostinelli for Misultin! | |
| ######################################################################## | |
| ###################### Nginx ########################################### | |
| ######################################################################## | |
| ## Testing Nginx with http://owns.ch/pong |