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 chai import Chai | |
class CustomObject (object): | |
def get(self, arg): | |
pass | |
class TestCase(Chai): | |
def test_mock_get(self): | |
obj = CustomObject() | |
expect(obj.get).args('name').returns('My Name') |
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 pymongo.connection import Connection, _str_to_node | |
from pymongo.master_slave_connection import MasterSlaveConnection | |
from pymongo.errors import AutoReconnect,DuplicateKeyError,CollectionInvalid | |
import time | |
# validate slaves every 5 minutes | |
VALIDATE_INTERVAL = 5 * 60 | |
class ClusterConnection(MasterSlaveConnection): |
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
# /usr/share/X11/xorg.conf.d/52-synaptics-np900x3c.conf | |
# | |
# There are a lot of examples out there; they and the (K)Ubuntu defaults suck. Keeping this updated as I work to | |
# make my awesome laptop usable. | |
# Configure clickpad for Samsung Series 9 (NP900X3C). | |
Section "InputClass" | |
Identifier "np900x3c clickpad" | |
MatchIsTouchpad "on" | |
MatchDevicePath "/dev/input/event*" |
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 grep -l 'libssl.*deleted' /proc/*/maps | tr -cd 0-9\\n | xargs -r ps u | |
USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND | |
* 794 0.5 2.3 3805132 186696 ? Sl Mar18 194:22 /usr/bin/amarok | |
* 3351 0.0 0.1 456840 9940 ? S Mar10 0:04 python /usr/bin/printer-applet | |
* 11789 0.0 0.1 86420 10540 ? S Apr04 0:00 /usr/bin/python /usr/share/apt-xapian-index/update-apt-xapian-index-dbus |
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 simple node.js proxy which will force SSL encryption on support.yourcompany.com | |
// and forward through the secure tenderapp domain for your support account. | |
// npm install http-proxy | |
var fs = require('fs'), | |
http = require('http'), | |
httpProxy = require('http-proxy'); | |
httpProxy.createServer({ | |
ssl: { |
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
export CUR_BRANCH=$(git name-rev --name-only HEAD) && git diff --name-only $CUR_BRANCH $(git merge-base $CUR_BRANCH master) | grep .py | xargs flake8 |
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/bash | |
# Place in .git/hooks/pre-commit | |
# Filters out deleted files with --diff-filter | |
# GNU | |
git diff --cached --name-only --diff-filter=ACMRTUXB | grep .py | xargs --no-run-if-empty flake8 $FLAKE | |
# BSD | |
git diff --cached --name-only --diff-filter=ACMRTUXB | (grep .py || echo " ") | xargs flake8 $FLAKE |
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/bash | |
# Thank you to the person who answered a long-lost post on the internet with this code, | |
# which I have been using successfully for many years | |
sudo dpkg -l 'linux-*' | sed '/^ii/!d;/'"$(uname -r | sed "s/\(.*\)-\([^0-9]\+\)/\1/")"'/d;s/^[^ ]* [^ ]* \([^ ]*\).*/\1/;/[0-9]/!d' | xargs sudo apt-get purge $@ |
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/bash | |
# Fetch a file from a host in a datacenter. Example: | |
# ./get-file.sh my-datacenter my-host ~/my.file | |
# spawn tunnel | |
ssh -n -t -t -L 22000:$2:22 $1 & | |
TUNNEL=$! | |
sleep 5 |
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/bash | |
# Fetch a file from a host in a datacenter. Example: | |
# ./put-file.sh my-datacenter my-host ~/local.file ~/my.file | |
# spawn tunnel | |
ssh -n -t -t -L 22000:$2:22 $1 & | |
TUNNEL=$! | |
sleep 5 |