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
// Sublime Text | |
{ | |
"color_scheme": "Packages/Color Scheme - Default/Twilight.tmTheme", | |
"font_face": "DejaVu Sans Mono", | |
"font_size": 10, | |
"ignored_packages": | |
[ | |
"Vintage" | |
], | |
"translate_tabs_to_spaces": 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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.background { | |
fill: #e7e7e7; | |
} | |
.axis path, | |
.axis 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
# Clear local merged branches | |
function clearbranches(){ | |
cur_branch=`git rev-parse --abbrev-ref HEAD` | |
if [[ "$cur_branch" == "master" ]]; then | |
git branch --merged | grep -v "\*" | xargs -n 1 git branch -d | |
else | |
echo "Not on master branch!" | |
fi | |
} |
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
<!DOCTYPE html> | |
<meta charset="utf-8"> | |
<style> | |
.svg { | |
border: 1px solid #000; | |
} | |
.result { | |
color: #05c; |
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 guess_encoding(s): | |
"""Guess the character encoding from a byte string.""" | |
# Check BOM | |
# 0xFF, 0xFE -> UTF-16 LE | |
# 0xFE, 0xFF -> UTF-16 BE | |
# 0xEF, 0xBB, 0xBF -> UTF-8 | |
bom = s[0:2] | |
if bom == '\xff\xfe': | |
return 'utf-16' | |
elif bom == '\xfe\xff': |
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 logging | |
import time | |
from celery import shared_task as orig_shared_task | |
def timeit(func): | |
"""A decorator used to log the function execution time.""" | |
logger = logging.getLogger('tasks') |
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
#!/Users/YOUR_USERNAME/.pyenv/versions/3.6.2/envs/alfred/bin/python | |
import functools | |
import json | |
import os | |
from datetime import datetime | |
from threading import Thread | |
import requests |
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
sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ `lsb_release -cs`-pgdg main" > /etc/apt/sources.list.d/pgdg.list' | |
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add - | |
sudo apt-get update | |
sudo apt-get upgrade | |
# sudo apt-get install postgresql-9.3 | |
# sudo apt-get install postgresql-client-9.3 |
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
httplogger() { | |
while true; do | |
echo -e "HTTP/1.1 200 OK\r\n\r\nok" | nc -vl 8989 | |
test $? -gt 128 && break | |
echo | |
echo '----------------------------------------' | |
done | |
echo | |
} |
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 minimal web server that runs shell commands, powered by Tornado and its | |
Subprocess module. It does non-blocking IO and streams the response. | |
To start the server: | |
$ python tornado_subprocess.py | |
To send a shell command using httpie: |