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 pytest | |
class DictHasValus(dict): | |
""" | |
DictHasValus({('foo', 'bar'): 'hello'}) == {'foo': {'bar': 'hello'}} | |
""" | |
def __eq__(self, other): | |
try: |
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
# tmux v2.0 installation steps for Ubuntu 14.04 (Trusty Tahr) | |
# tmux -V | |
# sudo apt-get update | |
# sudo apt-get install -y python-software-properties software-properties-common | |
# sudo add-apt-repository -y ppa:pi-rho/dev | |
# sudo apt-get update | |
# sudo apt-get install -y tmux | |
# tmux -V | |
# use UTF8 |
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 sublime, sublime_plugin | |
class DuplicateLineCommand(sublime_plugin.TextCommand): | |
def run(self, edit): | |
for region in self.view.sel(): | |
if region.empty(): | |
line = self.view.line(region) | |
line_contents = self.view.substr(line) + '\n' | |
self.view.insert(edit, line.begin(), line_contents) |
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/bin/env python | |
import glob | |
import os | |
import sys | |
if len(sys.argv) < 2: | |
print "Usage: ./cleanup.py path/to/dir/ [max_dir_size_in_gb]" | |
sys.exit() |
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
# ~/.bashrc: executed by bash(1) for non-login shells. | |
# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) | |
# for examples | |
# If not running interactively, don't do anything | |
[ -z "$PS1" ] && return | |
# don't put duplicate lines or lines starting with space in the history. | |
# See bash(1) for more options | |
HISTCONTROL=ignoreboth |
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 | |
target="$1" | |
remotePath="$2" | |
device="${3:-/dev/ttyUSB0}" | |
# compress target files using tar | encode data to base64 string | remove \n | |
compress="tar -C `dirname $target` -cjvf - `basename $target` | base64 | tr -d '\n'" | |
# decode base64 string using python (using python because my device doesn't have base64) | |
base64decode="import base64, sys; sys.stdout.write(base64.b64decode(sys.stdin.read()))" |
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
/** | |
* To run use http://nrabinowitz.github.com/pjscrape/ | |
* 1. $ phantomjs pjscrape.js audible.js | |
* 2. Register on mongolab.com | |
* 3. $ mongoimport -h ds0466148.mongolab.com:45598 -d <dbname> -c <collection> -u <user> -p <password> --file audible.json --jsonArray | |
* 4. Install greasemonkey (Firefox) or tempermonkey (Chrome) | |
* 5. Add this userscript https://gist.github.com/gornostal/6570526 | |
* 6. Open https://mongolab.com/databases/audible/collections/fiction_books or whatever you have | |
*/ |
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
// ==UserScript== | |
// @name Audible-Mongolab | |
// @namespace http://use.i.E.your.homepage/ | |
// @version 0.1 | |
// @description https://gist.github.com/gornostal/6570516 | |
// @match https://mongolab.com/databases/audible/collections/* | |
// @copyright 2012+, You | |
// ==/UserScript== | |
- sudo -i
- cd /var
- dd if=/dev/zero of=swap.file bs=1M count=2048
- mkswap swap.file
- chmod 600 swap.file
- swapon swap.file
- // copy UUID
- vi /etc/fstab ==>
UUID=f1ed55b6-357b-4427-86c8-d57f034cf29e none swap defaults 0 0
- mount -a
- echo $? // should be 0 if everything is OK
OlderNewer