Key Binding | Action |
---|---|
Ctrl-r | History reverse search |
Ctrl-a | Jump to BOL |
Ctrl-e | Jump to EOL |
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
class Singleton(object): | |
""" | |
Singleton interface: | |
http://www.python.org/download/releases/2.2.3/descrintro/#__new__ | |
""" | |
def __new__(cls, *args, **kwds): | |
it = cls.__dict__.get("__it__") | |
if it is not None: | |
return it |
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
from subprocess import PIPE, Popen | |
from signal import alarm, signal, SIGALRM, SIGKILL | |
import logging | |
from traceback import format_exception | |
import sys | |
class RuntimeException(Exception): | |
pass | |
class Bash: |
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
source ~/.git-completion.sh | |
alias gco='git co' | |
alias gci='git ci' | |
alias grb='git rb' | |
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
#!flask/bin/python | |
from flask import Flask, jsonify, abort, request, make_response, url_for | |
from flask.ext.httpauth import HTTPBasicAuth | |
app = Flask(__name__, static_url_path = "") | |
auth = HTTPBasicAuth() | |
@auth.get_password | |
def get_password(username): | |
if username == 'miguel': |
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
/* index size per db */ | |
SELECT DBName,CONCAT(LPAD(FORMAT(SDSize/POWER(1024,pw),3),17,' '),' ', | |
SUBSTR(' KMGTP',pw+1,1),'B') "Data Size",CONCAT(LPAD( | |
FORMAT(SXSize/POWER(1024,pw),3),17,' '),' ',SUBSTR(' KMGTP',pw+1,1),'B') "Index Size", | |
CONCAT(LPAD(FORMAT(STSize/POWER(1024,pw),3),17,' '),' ', | |
SUBSTR(' KMGTP',pw+1,1),'B') "Total Size" FROM | |
(SELECT IFNULL(DB,'All Databases') DBName,SUM(DSize) SDSize,SUM(XSize) SXSize, | |
SUM(TSize) STSize FROM (SELECT table_schema DB,data_length DSize, | |
index_length XSize,data_length+index_length TSize FROM information_schema.tables | |
WHERE table_schema NOT IN ('mysql','information_schema','performance_schema')) AAA |
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/sh | |
# download this script | |
# make sure s3cmd is installed | |
# yum install s3cmd | |
# if yum mentioned above does not work then | |
# wget http://downloads.sourceforge.net/project/s3tools/s3cmd/1.5.0-alpha1/s3cmd-1.5.0-alpha1.tar.gz | |
# tar xvf s3cmd-1.5.0-alpha1.tar.gz | |
# cd s3cmd-1.5.0-alpha1 | |
# python setup.py install | |
# python 2.6+ is required |
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
#!/usr/bin/python -W ignore::DeprecationWarning | |
# | |
# Copyright (C) 2009 Google Inc. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# |
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 try_utf8(data): | |
"Returns a Unicode object on success, or None on failure" | |
try: | |
return data.decode('utf-8') | |
except UnicodeDecodeError, ue: | |
print ue | |
return None | |
# vim e! ++enc=utf8 |
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 | |
repos=( repo03 repo04 ) | |
for dir in $(seq 0 $((${#repos[@]} - 1))) | |
do | |
if [ ! -d "server_repo/${repos[$dir]}.git" ]; then | |
echo "${repos[$dir]}" | |
echo "creating repos" | |
mkdir -p server_repo/${repos[$dir]}.git |