- Making lists with stuff in them
- access just like strings!
- O-indexed
- assignment with
list[index]
syntax, touch on mutability ("this can be changed, strings can't")
import inspect | |
from types import FunctionType | |
from collections import defaultdict | |
class FactoryDict(defaultdict): | |
""" | |
>>> fd = FactoryDict(int) | |
>>> fd['foo'] += 7 | |
>>> fd['foo'] | |
7 |
red="\[\e[0;31m\]" | |
green="\[\e[0;32m\]" | |
yellow="\[\e[0;33m\]" | |
purple="\[\e[0;35m\]" | |
cyan="\[\e[0;36m\]" | |
end="\[\e[0m\]" | |
GIT_PS1_SHOWUPSTREAM=auto | |
GIT_PS1_SHOWSTASHSTATE=true | |
GIT_PS1_SHOWDIRTYSTATE=true |
from collections import defaultdict | |
import functools | |
class multimethod(object): | |
""" | |
multimethod.register('function', dispatcher) | |
@multimethod.register('function') | |
def dispatcher(): pass |
from collections import defaultdict | |
import functools | |
class Registry(object): | |
def __init__(self): | |
self.dispatchers = {} | |
self.functions = defaultdict(dict) | |
def __enter__(self): |
red="\[\e[0;31m\]" | |
green="\[\e[0;32m\]" | |
yellow="\[\e[0;33m\]" | |
purple="\[\e[0;35m\]" | |
cyan="\[\e[0;36m\]" | |
end="\[\e[0m\]" | |
#curl https://raw.github.com/git/git/master/contrib/completion/git-completion.bash -o ~/.git-completion.bash | |
if [ -f ~/.git-completion.bash ] | |
then |
{ | |
"dependencies": { | |
"johnny-five": "git+ssh://[email protected]:rwldrn/johnny-five.git" | |
} | |
} |
app.all '/push/*', (request, response) -> | |
response.json 503, {} | |
app.get '/api/v2/user_messages', (request, response) -> | |
response.json 200, {messages: [{message_heading: 'Scheduled Maintenance', message_text: 'We are currently conducting maintenance'}]} # in-app messaging! | |
app.all '/api/*', (request, response) -> | |
response.json 503, {} | |
app.all '/*', (request, response) -> | |
response.setHeader 'Retry-After', '3600' | |
response.send 503, render503Page() # renders html for web 503 page |
package main | |
import ( | |
"fmt" | |
"github.com/codegangsta/martini-contrib/binding" | |
"github.com/go-martini/martini" | |
"gopkg.in/mgo.v2" | |
"gopkg.in/mgo.v2/bson" | |
"net/http" | |
) |
package main | |
import ( | |
"encoding/json" | |
"fmt" | |
"github.com/codegangsta/martini-contrib/binding" | |
"github.com/go-martini/martini" | |
"github.com/shopify/sarama" | |
"net/http" | |
) |