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
package main | |
import ( | |
"bytes" | |
"encoding/json" | |
"fmt" | |
"log" | |
"os" | |
) |
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
package main | |
import ( | |
"crypto/sha1" | |
"encoding/json" | |
"flag" | |
"fmt" | |
"hash/crc64" | |
"io/ioutil" | |
"log" |
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 | |
export V= | |
check_size() { | |
wd=${1:-.} | |
indent=${2} | |
#echo "${indent}${wd}: " | |
du -h -d1 "${wd}" | ( | |
while read line; do |
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
# I'm getting Amethyst for my dual-monitor work setup | |
# | |
# For laptop, I'm replacing good-old Spectacle with Slate | |
# just for its Grid / Hint and versionable configuration | |
# to start with. | |
# https://github.com/jigish/slate | |
bind 0:alt,cmd relaunch | |
bind 1:alt,cmd grid 0:6,4 | |
bind 2:alt,cmd hint |
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 sched, time | |
class O(object): | |
def __init__(self, name): | |
self.name = name | |
def print_time(self): | |
print("({}): From print_time {}".format(self.name, time.time())) | |
def entry(self): | |
s = sched.scheduler(time.time, time.sleep) | |
s.enter(2, 1, self.print_time, ()) |
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 __future__ import print_function | |
def schmitt_trigger(lo, hi, cb, value): | |
"""http://en.wikipedia.org/wiki/Schmitt_trigger""" | |
while True: | |
newvalue = (yield value) | |
if newvalue is None: | |
raise StopIteration() | |
if newvalue >= hi and value < hi: | |
cb(hi, newvalue, 'to-hi') |
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
# Originally from: http://dustymabe.com/2014/05/10/zero-to-wordpress-on-docker-in-5-minutes/ | |
FROM goldmann/f20 | |
MAINTAINER Dusty Mabe | |
# Install httpd and update openssl | |
RUN rpm -Uvh http://kojipkgs.fedoraproject.org//packages/yum/3.4.3/120.fc20/noarch/yum-3.4.3-120.fc20.noarch.rpm | |
RUN yum update -y | |
RUN yum install -y httpd openssl unzip php php-pdo wget |
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 subprocess as sp | |
def list_revs(path, limit=10): | |
""" Parse output from svn log and find log headers. Maybe fooled if log entry contains some other svn log entries, etc.""" | |
out = sp.check_output('svn log -l {limit} {path}'.format(path=path, limit=limit), shell=True) | |
lines = out.split('\n') | |
for pre, line, space in zip(lines[:-2], lines[1:], lines[2:]): | |
if pre.startswith('-------') and space.strip() == '': | |
parts = line.split('|') | |
if len(parts) == 4 and parts[0].startswith('r'): |
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 gevent | |
import logging | |
import requests | |
try: | |
import simplejson as json | |
except: | |
import json | |
from gevent.pool import Group, Pool |
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 gevent | |
from gevent import Greenlet | |
from gevent.queue import Queue | |
from gevent.lock import BoundedSemaphore | |
class Worker(object): | |
def __init__(self, *a, **kw): | |
self._glet = Greenlet(self.run, *a, **kw) | |
self._q = Queue() |
NewerOlder