This file contains hidden or 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
git reflog | |
git reflog show <your-feature-branch> | |
git reset --hard <commit> |
This file contains hidden or 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
-- check on creation status | |
SELECT * FROM pg_stat_progress_create_index; | |
-- look for broken indexes | |
SELECT * FROM pg_class, pg_index WHERE pg_index.indisvalid = false AND pg_index.indexrelid = pg_class.oid; | |
-- fix | |
REINDEX INDEX CONCURRENTLY idx_users_email_2019; | |
-- find unused indexes |
This file contains hidden or 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
func NetworkSize(cidr string) int { | |
_, ipnet, err := net.ParseCIDR(cidr) | |
if err != nil { | |
return 0 | |
} | |
ones, bits := ipnet.Mask.Size() | |
exp := uint(bits - ones) | |
size := 1 << exp | |
return size | |
} |
This file contains hidden or 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
(setq make-backup-files nil) ; stop creating backup~ files | |
(setq auto-save-default nil) ; stop creating #autosave# files | |
(global-set-key "\C-w" 'backward-kill-word) | |
(global-set-key "\C-x\C-k" 'kill-region) | |
(global-set-key "\C-x\C-m" 'execute-extended-command) | |
(require 'ido) | |
(ido-mode t) | |
(ido-everywhere t) | |
(defun ido-settings () |
This file contains hidden or 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 MySQLdb | |
import logging | |
log = logging.getLogger(__name__) | |
class StreamingMysqlClient(object): | |
def __init__(self, host, user, password, dbname): | |
self.conn = MySQLdb.connect(host, user, password, dbname) | |
def stream_query(self, query): |
This file contains hidden or 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
# -*- mode: shell-script -*- | |
export EDITOR='emacs' | |
export PATH=$HOME/bin:$PATH | |
export WORKON_HOME=$HOME/.virtualenvs | |
source /usr/local/bin/virtualenvwrapper.sh | |
alias ggs='git status' | |
alias ggbl='git branch --list' | |
alias ee='emacs -nw' | |
alias eew='emacs' |
This file contains hidden or 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 | |
# README: | |
# the first time you run this, you'll need to setup your | |
# certificate store (feel free to create these directories | |
# whereever you feel is appropriate): | |
# | |
# mkdir $HOME/ssl | |
# cd $HOME/ssl | |
# mkdir csr newcerts |
This file contains hidden or 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
filename=access_log.log | |
output_filename=${filename}_pruned | |
start_pattern='2013:13:' | |
end_pattern='2013:16:30:' | |
start=`grep -n -m1 "$start_pattern" $filename | cut -f1 -d:` | |
end=`grep -n -m1 "$end_pattern" $filename | cut -f1 -d:` | |
sed -n "$start,${end}p" $filename > $output_filename |
This file contains hidden or 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 wait_for_true(timeout=60, sleep=1.0): | |
def _wait_for_true(f): | |
def __wait_for_true(*args, **kwargs): | |
start_time = time.time() | |
ret_val = False | |
while (not ret_val and | |
timeout is not None and | |
time.time() - start_time < timeout): | |
ret_val = f(*args, **kwargs) | |
time.sleep(sleep) |
This file contains hidden or 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 MySQLdb | |
class SimpleDB(object): | |
def __init__(self, h, u, p, fetchsize=10000): | |
self.db = MySQLdb.connect(host=h, user=u, passwd=p) | |
self.cursor = self.db.cursor() | |
self.cursor.arraysize = fetchsize | |
def query(self, q, params = None): | |
'''note: if you're using more recent pythons, you can change |
NewerOlder