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 functools | |
import pymongo | |
import logging | |
import time | |
MAX_AUTO_RECONNECT_ATTEMPTS = 5 | |
def graceful_auto_reconnect(mongo_op_func): | |
"""Gracefully handle a reconnection event.""" | |
@functools.wraps(mongo_op_func) |
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
# Author: Anthony Wu | |
# A quick way to make Python enum classes. | |
# Uses range/enumerate to quickly generate a list of enumerated values, | |
# but only safe/useful for your application logic where you don't have | |
# to persist these values to a data store. | |
# Example A: hard code enum classes | |
class Fruits(object): |
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
""" | |
Copyright (c) 2012 Anthony Wu, twitter.com/anthonywu | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the | |
"Software"), to deal in the Software without restriction, including | |
without limitation the rights to use, copy, modify, merge, publish, | |
distribute, sublicense, and/or sell copies of the Software, and to | |
permit persons to whom the Software is furnished to do so, subject to | |
the following conditions: |
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 foobar(a, b, c, (username, password)=(None,None)): | |
print a, b, c, username, password | |
foobar(1, 2, 3, ('hello','world')) # 1 2 3 hello world | |
foobar(1, 2, 3) # prints "1 2 3 None None" |
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
# Point end-of-life Ubuntu versions' apt source URLs to old-releases.* | |
# See: https://help.ubuntu.com/community/EOLUpgrades | |
sudo sed -i s/us.archive.ubuntu/old-releases.ubuntu/g /etc/apt/sources.list | |
sudo sed -i s/security.ubuntu/old-releases.ubuntu/g /etc/apt/sources.list | |
sudo apt-get update |
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
(add-to-list 'load-path "~/.emacs-lisp") | |
;; Auto-Complete | |
(require 'anything) | |
;; Python nice-to-haves | |
(require 'lambda-mode) | |
(add-hook 'python-mode-hook #'lambda-mode 1) | |
(setq lambda-symbol (string (make-char 'greek-iso8859-7 107))) |
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
function pdf_join { | |
join_py="/System/Library/Automator/Combine PDF Pages.action/Contents/Resources/join.py" | |
read -p "Name of output file > " output_file && "$join_py" -o $output_file $@ && open $output_file | |
} |
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
# checkout git-review from GitHub and install | |
# note: this is not the same git-review available via pip installer | |
git clone [email protected]:facebook/git-review.git | |
cd git-review/ | |
sudo python setup.py install | |
# assuming you have Homebrew installed | |
brew install tkdiff |
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
# run with sudo user privileges | |
wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo apt-key add - | |
sudo sh -c 'echo "deb http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' | |
sudo chmod 644 /etc/apt/sources.list.d/google-chrome.list | |
sudo apt-get update | |
sudo apt-get install google-chrome-stable |
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
# install via Homebrew | |
brew install memcached | |
# optional: make memcached start along with the system | |
ln -sfv /usr/local/opt/memcached/*.plist ~/Library/LaunchAgents | |
# load memcached now for immediate use | |
launchctl load ~/Library/LaunchAgents/homebrew.mxcl.memcached.plist | |
# check the process that just launched |
OlderNewer