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 interleave_chunks(lists): | |
while lists: | |
items, amount = lists.pop(0) | |
subset = items[0:amount] | |
items = items[amount:] | |
if subset: | |
for item in subset: | |
yield item |
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
import sys | |
lines = sys.stdin.readlines() | |
lines.sort(reverse = ('-r' in sys.argv)) | |
print ''.join(lines) |
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
import sys | |
def process_lines(lines): | |
for index, line in enumerate(lines): | |
last_line = lines[index - 1] | |
if line != last_line: | |
sys.stdout.write(line) | |
process_lines(sys.stdin.readlines()) |
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 strip_string(self, string): | |
"""Cleans a string based on a whitelist of printable unicode categories | |
You can find a full list of categories here: | |
http://www.fileformat.info/info/unicode/category/index.htm | |
""" | |
letters = ('LC', 'Ll', 'Lm', 'Lo', 'Lt', 'Lu') | |
numbers = ('Nd', 'Nl', 'No') | |
marks = ('Mc', 'Me', 'Mn') | |
punctuation = ('Pc', 'Pd', 'Pe', 'Pf', 'Pi', 'Po', 'Ps') |
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
import os | |
import beanstalkc | |
beanstalk = beanstalkc.Connection(host='localhost', port=14711) | |
while True: | |
job = beanstalk.reserve() | |
print "Running %s" % job.body | |
os.system(job.body) | |
job.delete() |
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
brew install mplayer && mplayer "http://livestream-f.akamaihd.net/398160_1594566_3e41227e_1_678@41915?v=2.10.3&fp=MAC%2011,5,31,2&r=HPMHI&g=MYFXUTYHSWLA" |
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
from github import Github # https://github.com/jacquev6/PyGithub | |
g = Github("USER", "PASSWORD") | |
repos = g.get_organization('ORGNAME').get_repos() | |
for repo in repos: | |
repo.create_hook( | |
"irc", | |
{ |
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
image/*; ~/.showinbrowser.sh %s | |
application/*; ~/.showinbrowser.sh %s | |
audio/*; ~/.showinbrowser.sh %s | |
text/*; ~/.showinbrowser.sh %s |
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
#!/bin/sh | |
# An xkcd://318 URL handler, for linux types. | |
echo -n "#!/bin/sh\nexec xdg-open \`echo \"\$@\" | sed -e 's/xkcd:\//http:\/\/xkcd.com/'\`" > $HOME/.xkcdhandler | |
chmod +x $HOME/.xkcdhandler | |
gconftool-2 -t string -s /desktop/gnome/url-handlers/xkcd/command "$HOME/.xkcdhandler %s" | |
gconftool-2 -t bool -s /desktop/gnome/url-handlers/xkcd/needs_terminal false | |
gconftool-2 -t bool -s /desktop/gnome/url-handlers/xkcd/enabled true |
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
#include <nfc/nfc.h> | |
#include <nfc/nfc-messages.h> | |
int main () | |
{ | |
nfc_device_t *nfcDev; | |
nfcDev = nfc_connect(NULL); | |
if (nfcDev == NULL) { | |
printf("Cannot connect to the RFID reader.\n"); |