Skip to content

Instantly share code, notes, and snippets.

View washort's full-sized avatar

Allen Short washort

View GitHub Profile
import sys
from logging import StreamHandler
from flask_oauth import OAuth
from flask import session, Flask, url_for, request
app = Flask("oauth_test_app")
app.secret_key = "flask secret"
app.logger.addHandler(StreamHandler(sys.stdout))
mkt_app = OAuth().remote_app(
'marketplace',
@washort
washort / example.py
Created June 4, 2013 22:32
celery confusing behaviour
from celery import Celery, group
celery = Celery('tasks', backend='amqp', broker='amqp://test@localhost//')
celery.conf.CELERY_IGNORE_RESULT = True
@celery.task(ignore_result=False)
def inc(x):
return x + 1
from celery import Celery, group
celery = Celery('tasks', backend='amqp', broker='amqp://...')
#celery.conf.CELERY_ALWAYS_EAGER = True
@celery.task
def test_task(x, y):
return [x, y]
def test():
from celery import Celery, group
celery = Celery('tasks', backend='amqp', broker='amqp://zamboni:zamboni@localhost:5672/zamboni')
celery.conf.CELERY_ALWAYS_EAGER = True
@celery.task
def test_task(x, y):
return [x, y]
c1 = test_task.si(3, 4) | test_task.si(5, 6)
payload :typ :ttl :rdl =
?(typ == 'A') <anything{4}>:address
-> DNSParser.getType('A', ttl=ttl, address=address)
| ?(typ == 'A6') byte:pfl (-> int((128 - pfl) / 8.0)):bl
(-> '::'):sf (-> b''):n
(?(bl) <anything{bl}>:sf)? (?(pfl) typ:n)?
-> DNSParser.getType('A6', ttl=ttl, prefixLen=pfl, suffix=sf, prefix=n.name)
| ?(typ == 'AAAA') <anything{16}>:address
-> DNSParser.getType('AAAA', ttl=ttl, address=address)
@washort
washort / gist:5942415
Last active December 19, 2015 10:39
some ideas, probably
There are four places.
1. Load site. def obj := <import:fqn.named.obj>
2. Dependency site. fqn.named.obj => washort42@gmail.com-20130705190320-tldtfzfh5wpzuct7
3. Requirement site. washort42@gmail.com-20130705190320-tldtfzfh5wpzuct7 => https://launchpad.net/monte
4. Eval site. fqn.named.obj => def obj { to doStuff(...) {}}
A stdlib isn't necessary and a global scope isn't
necessary. Presumably there'll be a bootstrap scope only containing
VM-implemented prims but only scope-constructing code will run
there. Deployment means building an environment that maps some FQNs to
import json
from twisted.internet import Protocol
class StorageMgmtClient(protocol.Protocol):
def __init__(self):
self._buffer = ''
self.pendingRequests = []
self.msgid = 0
@washort
washort / readability.md
Last active December 22, 2015 00:09
On Readability

On Readability

Programs must be written for people to read, and only incidentally for machines to execute. — Abelson & Sussman, Structure and Interpretation of Computer Programs

Code readability gets talked about a lot these days. I haven't yet heard from anyone who's opposed to it. Unfortunately, learning to read code is a skill rarely discussed and even more rarely taught. As the SICP quote above points out, readability is perhaps the most important

module Func where
import Language.BASIC
main :: IO ()
main = runBASIC' $ do
10 FOR X := 0 TO 2.01 STEP 0.1
30 PRINT SIN(X);" ";COS(X);" ";TAN(X);" ";ATN(X);" ";EXP(X);" ";LOG(X);" ";SQR(X);" ";ABS(X);" ";SGN(X);" ";INT(X);" ";RND(X);" ";X
40 NEXT X
100 END
def generate_LiteralExpr(self, out, ctx, node):
def generate_NounExpr(self, out, ctx, node):
def generate_BindingExpr(self, out, ctx, node):
def generate_SeqExpr(self, out, ctx, node):
def generate_MethodCallExpr(self, out, ctx, node):
def generate_Def(self, out, ctx, node):
def generate_Escape(self, out, ctx, node):
def generate_Object(self, out, ctx, node):
def generate_Assign(self, out, ctx, node):
def generate_Finally(self, out, ctx, node):