Skip to content

Instantly share code, notes, and snippets.

View bitprophet's full-sized avatar
🎯
Focusing

Jeff Forcier bitprophet

🎯
Focusing
View GitHub Profile

The setup:

  • Some top level tasks
  • A 'docs' submodule
  • docs.build is configured to be the default task for 'docs'
  • So, 'invoke docs' == 'invoke docs.build'. Either is allowed.

The question is, how should this setup display in --list? Our options:

  1. Fab 1.x style: display both, no indication of what maps to what:
from fabric.api import parallel, execute, sudo
@parallel
def uptime():
sudo('uptime')
def do_my_stuff():
execute(uptime, hosts=['web1', 'web2'])
# Bad
foo \
bar
# Good
foo \
bar
@bitprophet
bitprophet / bad.py
Created April 17, 2012 05:26 — forked from idan/gist:2403662
Parameter Usage Style
>>> def init(headers={}):
... print "headers before: %r" % headers
... headers['foo'] = 'bar'
... print "headers after: %r" % headers
...
...
>>> init()
headers before: {}
headers after: {'foo': 'bar'}
>>> init()
@bitprophet
bitprophet / gist:1503116
Created December 20, 2011 20:25 — forked from blech75/gist:1503089
markdown and lists

i want to be able to do this:


# grocery list

* apples
* bananas
* strawberries
@bitprophet
bitprophet / test_grok.rb
Created December 16, 2011 20:15
How to quickly test pure-Ruby Grok pattern strings
# Obtain pure-Ruby lib
require 'grok-pure'
# Create grok instance
grok = Grok.new
# Map some regex patterns to pattern names; this sets up %{FOO}
grok.add_pattern("FOO", "[abc]")
# And/or load from file -- highly useful is the patterns/grok-patterns file that ships with Logstash source
import csv
import json
import os
import sys
from collections import defaultdict
from dateutil.parser import parse as dateparse
import requests
import csv
import json
import sys
from collections import defaultdict
from dateutil.parser import parse as dateparse
count = int(sys.argv[2]) if len(sys.argv) > 2 else None
seconds = defaultdict(int)
# Output of https://github.com/bitprophet/seven/blob/master/2-io/day1/answers.io
# at 6a42e4c454eb6eb6499bc1264efa34fc22d3fa15
-- Type strength --
Strongly typed
Still strongly typed
-- Truthiness --
0 is true
empty string is true
@bitprophet
bitprophet / gist:1189894
Created September 2, 2011 20:56
Partial Cony settings file
def github(query, url):
url = "https://github.com/%s/issues" % url
# Direct to issue number
try:
redirect("%s/%s" % (url, int(query)))
except ValueError:
# New ticket
if query == "new":
redirect("%s/new" % url)
# Issue list