Skip to content

Instantly share code, notes, and snippets.

@inlinestyle
inlinestyle / flow-disjoint-union-checking.js
Created August 30, 2016 15:19
Example of flow disjoint union checking not carrying through closures
// @flow
type A = {
lower: 'a'
}
type B = {
lower: 'b',
bMethod: Function
}
class GCFixedColumnHorizontalScrollingCollectionViewFlowLayout: UICollectionViewFlowLayout {
var numberOfRows: UInt = 0
var numberOfFixedColumns: UInt = 0
var columnWidth: UInt = 0
init(numberOfFixedColumns: UInt, columnWidth: UInt) {
self.numberOfFixedColumns = numberOfFixedColumns
self.columnWidth = columnWidth
super.init()
self.scrollDirection = .Horizontal
@inlinestyle
inlinestyle / lecture.md
Last active August 29, 2015 14:14
Lecture outline for Python Lists/Dicts talk

Lists:

  • Making lists with stuff in them

Item Access

  • access just like strings!
  • O-indexed
  • assignment with list[index] syntax, touch on mutability ("this can be changed, strings can't")

Length

@inlinestyle
inlinestyle / optimus.go
Last active August 29, 2015 14:06
HTTP/JSON API that consumes stream/event POSTs and publishes them to a local Kafka cluser
package main
import (
"encoding/json"
"fmt"
"github.com/codegangsta/martini-contrib/binding"
"github.com/go-martini/martini"
"github.com/shopify/sarama"
"net/http"
)
@inlinestyle
inlinestyle / megatron.go
Created September 5, 2014 03:56
Boilerplate for a stream API in go
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"
)
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
@inlinestyle
inlinestyle / package.json
Created February 16, 2013 17:42
package.json for johnny-five
{
"dependencies": {
"johnny-five": "git+ssh://[email protected]:rwldrn/johnny-five.git"
}
}
@inlinestyle
inlinestyle / starter-profile.sh
Created February 12, 2013 18:38
Starter profile for designers, etc. The commented `curl` commands should be run in the shell to get git stuff working.
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
from collections import defaultdict
import functools
class Registry(object):
def __init__(self):
self.dispatchers = {}
self.functions = defaultdict(dict)
def __enter__(self):
from collections import defaultdict
import functools
class multimethod(object):
"""
multimethod.register('function', dispatcher)
@multimethod.register('function')
def dispatcher(): pass