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 | |
"""Describe EC2 instances bound to DNS name. Lookup CNAME of DNS, | |
which can point to ELB or EC2 instance. Get info from AWS API. | |
DNS names should be passed as arguments to the script. | |
Valid AWS API credentials must be configured, see | |
http://docs.pythonboto.org/en/latest/getting_started.html#configuring-boto-credentials | |
""" | |
from __future__ import print_function |
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 datetime import datetime | |
from subprocess import call | |
from mercury206 import commands, communications, config | |
def update_rrd(path, values): |
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 | |
rrdtool graph power.png --vertical-label=W*h --font=DEFAULT:11:Arial -w 900 -h 600 \ | |
DEF:apower=pcv.rrd:power:AVERAGE CDEF:whpower=apower,1000,\* LINE2:whpower#FF0000 |
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 | |
"""Checkout the latest version of git branch by name substring""" | |
from __future__ import print_function | |
import sys | |
from subprocess import check_output | |
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
$ for p in NUM1 NUM2; do curl -H "Accept: application/vnd.github.v3+json" \ | |
-H "Authorization: token OAUTH-TOKEN" \ | |
https://api.github.com/repos/:ORG:/:REPO:/pulls/$p/commits | \ | |
python -c "from flatdict import FlatDict; import json, csv, sys; rows = json.load(sys.stdin); \ | |
writer = csv.DictWriter(sys.stdout, [u'commit:author:name', u'commit:author:date', u'commit:tree:sha', u'commit:message'], extrasaction='ignore', delimiter='\t'); writer.writerows(FlatDict(row) for row in rows)" \ | |
> GH-PR-$p.txt; done |
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 antigravity | |
>>> antigravity.start() | |
'http://xkcd.com/353/' | |
# the source of http://pypi.python.org/pypi/antigravity/0.1 | |
# is plain and there is no any magic of Python | |
#!/usr/bin/env python | |
STRIP_URL = "http://xkcd.com/353/" |
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
__doc__ = "Add fly function to namespace where module is imported" | |
class RealWorldLevitation(Exception): | |
pass | |
def expose(obj): | |
import inspect | |
frame = inspect.currentframe() | |
frame.f_back.f_back.f_globals[obj.__name__] = obj | |
return obj |
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 subprocess | |
import readline | |
import select | |
import os | |
class Popen(subprocess.Popen): | |
def _communicate(self, input): | |
read_set = [] |
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
>>> tasks = Task.objects.\ | |
... extra(select = {'t': "date_trunc('minute', task_task.date_created)"}).\ | |
... values('t').annotate(Count('id')).order_by('t') | |
>>> print "\n".join("%(t)s | %(id__count)d" % t for t in tasks) | |
2011-01-19 11:26:00 | 767 | |
2011-01-19 11:27:00 | 613 | |
2011-01-19 11:28:00 | 522 | |
2011-01-19 11:29:00 | 721 | |
2011-01-19 11:30:00 | 701 | |
2011-01-19 11:31:00 | 679 |
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
python << END_PATH | |
import os | |
import vim | |
walker = os.walk(os.getcwd()) | |
dir_list = ['.'] | |
for root, dirs, paths in walker: | |
dir_list += map(lambda d: os.path.join(root, d), dirs) | |
vim.command('set path=%s' % ','.join(dir_list)) | |
END_PATH |
OlderNewer