view at http://bl.ocks.org/2970392
This file contains 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 | |
for repo in $(cat repos.txt); do | |
repodir=$(perl -pe 's!/!-!g;' -e 's/^analytics-//' <<< "$repo") | |
echo git clone --mirror ssh://gerrit.wikimedia.org/$repo.git $repodir | |
if git clone --mirror ssh://gerrit.wikimedia.org/$repo.git $repodir; then | |
echo | |
else | |
break | |
fi | |
done |
This file contains 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 | |
#/ jc -- jconsole via ssh proxy | |
#/ | |
#/ Usage: jc [options] HOST JMX_PORT [PROXY_PORT=JMX_PORT] [JMX_HOST=HOST] | |
#/ | |
#/ Starts a SOCKS proxy via ssh to connect to a | |
#/ JVM running on a remote and protected machine. | |
#/ | |
#/ Arguments: |
This file contains 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 sqlalchemy import * | |
class Haiku(Model): | |
id = Column(Integer, primary_key=True) | |
ctime = Column(DateTime, default=func.now()) | |
line1 = Column(Text()) | |
line2 = Column(Text()) | |
line3 = Column(Text()) | |
query = (Session.query(Haiku) |
This file contains 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 | |
#set -x | |
# Shows you the largest objects in your repo's pack file. | |
# Written for osx. | |
# | |
# @see http://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/ | |
# @author Antony Stubbs | |
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output |
This file contains 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 | |
#/ dsync -- Copy files to many hosts in parallel. | |
#/ | |
#/ Usage: dsync [options] -- [RSYNC_OPTIONS] SRC[...] DEST | |
#/ | |
#/ `dsync` copies files (using `rsync`) to many hosts in parallel. | |
#/ | |
#/ Where possible, `dsync` follows semantics of `dsh` and `rsync` -- it | |
#/ understands `~/.dsh/groups`, and uses `dsh`-like flags for specifying |
This file contains 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
# when you asked the question, this is what popped in my head; | |
# a solution to abstracting the requested problem into indexes | |
def combi(n, k): | |
r = [] | |
for i in range(n - k + 1): | |
for j in range(i + 1, n - k + 2): | |
s = [i] | |
for m in range(k - 1): | |
s.append(j + m) |
This file contains 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 | |
# -*- coding: utf-8 -*- | |
""" | |
Write me a function that takes a collection S and an integer k, and returns a | |
collection of all collections such that each is a sub-collection of S with size k. | |
- S is a set-like structure that guarantees these collections contain totally | |
ordered and unique values; importantly, [1,2] is the same as [2,1]. | |
- You can make sets as needed. | |
- They support indexing and slicing, as well as iteration. |
This file contains 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 | |
# -*- coding: utf-8 -*- | |
from IPython.core import ipapi | |
ip = ipapi.get() | |
### Auto-Activate VirtualEnv | |
import os, sys |
This file contains 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 json | |
from collections import OrderedDict | |
ordered_decoder = json.JSONDecoder(object_pairs_hook=OrderedDict) | |
class OrderedJSONDecoder(json.JSONDecoder): | |
""" As `JSONDecoder`, but passing `collections.OrderedDict` | |
for `object_pairs_hook` by default. | |
""" | |