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 sys | |
import math | |
from random import random | |
from PIL import Image, ImageOps, ImageEnhance | |
def dot(bits): | |
bits = bits & 7 | (bits & 112) >> 1 | (bits & 8) << 3 | bits & 128 | |
return unichr(0x2800 + bits) | |
class Grayscale24: |
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 datetime import datetime | |
import os | |
import re | |
import shutil | |
from PIL import Image, ExifTags | |
def get_exif_data(image): | |
return { | |
ExifTags.TAGS[k]: v |
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
cd ~ | |
wget -nc https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.0.1.zip | |
unzip -o -u elasticsearch-1.0.1.zip | |
cd elasticsearch-1.0.1/ | |
./bin/elasticsearch |
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
ack -o -h --python 'class\s.*Test.*\(\K.+(?=\)\:)' | sort | uniq |
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
sed -i -e 's/<TO_BE_REPLACED>/<NEW_STRING>/' `grep -lr --include=\*.py <SEARCH_STRING> .` |
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
SELECT | |
'index hit rate' as name, | |
(sum(idx_blks_hit) - sum(idx_blks_read)) / | |
sum(idx_blks_hit + idx_blks_read) as ratio | |
FROM pg_statio_user_indexes | |
union all | |
SELECT | |
'cache hit rate' as name, | |
case sum(idx_blks_hit) | |
when 0 then 'NaN'::numeric |
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 datetime import datetime, timedelta | |
get_random_datetime = lambda: datetime.now() - timedelta(days=random.randrange(1, 365*2), seconds=random.randrange(0, timedelta.max.seconds)) | |
dates = [get_random_datetime() for d in range(10)] | |
half_year_ago = datetime.now() - timedelta(days=365/2) | |
dates_within_last_six_months = filter(lambda date: date >= half_year_ago, dates) | |
deltas = [] | |
for index, date in enumerate(sorted(dates_within_last_six_months)): | |
if index < len(dates_within_last_six_months) - 1: |
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/env python | |
from paypal import PayPalConfig, PayPalInterface | |
config = {'API_USERNAME': None, | |
'API_PASSWORD': None, | |
'API_SIGNATURE': None} | |
paypal_config = PayPalConfig(**config) | |
paypal_interface = PayPalInterface(paypal_config) | |
# raises exception |
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 | |
# Usage: update_all <dir_prefix> <dir_prefix> ... | |
update_master () { | |
cd $1 | |
git checkout master | |
git pull upstream master | |
cd .. | |
} |
OlderNewer