Skip to content

Instantly share code, notes, and snippets.

View erikrose's full-sized avatar

Erik Rose erikrose

View GitHub Profile
def do_stuff(thing):
config = {
2: {'message': "Flibbety jibbet!"},
4: {'message': "A!\nFlibbety jibbet!"},
5: {'message': "B!\nFlibbety jibbet!"},
7: {'message': "C!", 'run_funcs': False},
}
if thing not in config:
return
print config[thing]['message']
>>> from json import dumps
>>> u = u'jörg'
>>> e = u.encode('utf-8')
>>> dumps(u)
'"j\\u00f6rg"'
>>> dumps(e)
'"j\\u00f6rg"'
@dstufft makes the point that fred==1.0.1 could represent fred…tar.gz,
fred…zip, or fred…wheel, etc. Right now, we don't care about the extension; we
just extract the package name from the downloaded file by means of a cheesy
heuristic. But what if an index entry makes available both a zip and a tarball?
Which does pip favor? With the current syntax, we support only a single hash. I
suppose we could count on pip keeping its format-favoring behavior stable over
time. Are we going to have a problem here?
  • Basic JS analysis for DXR
  • Index multiple trees (starting with comm-central and mozilla-aurora, the most commonly used ones on MXR)
  • Flexible, CORRECT deployment framework for DXR and others, to be factored out as Shiva. Goals: https://github.com/erikrose/shiva/tree/fast-burn#shiva
  • Socorro or L10n or other team priorities
@erikrose
erikrose / git-review
Created September 26, 2013 17:02
I made myself a "git review" subcommand which takes a user:branch pair pasted from a pull request page, like abbeyj:macro-use-extents, and does the fetch and checkout to get me ready to try it out. It's like 2 lines, but it's remarkable the mental weight it lifts. I no longer dread reviews. Just stick it in a file called "git-review" (no extensi…
#!/usr/bin/env python
from subprocess import check_output
from sys import argv
def main():
user, branch = argv[1].split(':')
check_output('hub fetch %s' % user, shell=True)
check_output('git checkout %s/%s' % (user, branch), shell=True)
print 'Now reviewing %s:%s.' % (user, branch)
@erikrose
erikrose / lights.py
Last active December 26, 2015 00:29
Open-source Halloween! Here's a spooky light show. Just `pip install blessings` and then run the script in any terminal. At the moment, it rotates between lightning-like flashes in various colors and gentle gradient pulsing. Put it in a window with the blinds down, and it diffuses nicely. Laptops are bright! Contribute your own effects in the co…
#!/usr/bin/env python
from itertools import chain
import random
from random import randint
from time import sleep, time
from blessings import Terminal
t = Terminal()
@erikrose
erikrose / gist:9233244
Last active August 29, 2015 13:56
Regex parser in Parsimonious
from parsimonious import Grammar # Get Parsimonious from https://pypi.python.org/pypi/parsimonious/.
# This recognizes a subset of Python's regex language, minus lookaround
# assertions, non-greedy quantifiers, and named and other special sorts of
# groups. Lucene doesn't support those, though we might be able to fake it
# later via some transformation.
regex_grammar = Grammar(r"""
regexp = branch another_branch*
branch = piece*
[DXR]
a = 1
b = 2
[some_tree]
source_folder = PWD/code
object_folder = PWD/code
build_command = make clean; make -j $jobs
[another_tree]
def full_traceback(callable, *args, **kwargs):
"""Work around the wretched exception reporting of concurrent.futures.
Futures generally gives no access to the traceback of the task; you get
only a traceback into the guts of futures, plus the description line of
the task's traceback. We jam the full traceback of any exception that
occurs into the message of the exception: disgusting but informative.
"""
try:
I think the reason open-source projects aren't great at churning out products
(or "finishing" them, as you so astutely word it—in the sense of "polishing")
is that the things that are interesting to work on are orthogonal to the
things that make a good product.
The advantage a hierarchal organization brings to product creation is focus.
It's what I enjoy about Apple: sometimes their products aren't for me, but
they're always *coherent*. I can see what they were going for. The Apple suite
of apps are clearly the best browser, calendar, and mailer for Steve Jobs.