This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Quote extends Backbone.Model | |
voteUp: => | |
d = $.post(@get('voteUp'), undefined, undefined, 'json') | |
d.done (data) => | |
@voted = true | |
@set data | |
voteDown: => | |
d = $.post(@get('voteDown'), undefined, undefined, 'json') | |
d.done (data) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM ubuntu:14.04 | |
RUN apt-get update && apt-get install -y build-essential git pigz zlib1g-dev vim curl libpq-dev | |
ADD . /halcyon | |
RUN ["/halcyon/halcyon", "paths"] | |
ENTRYPOINT ["/halcyon/halcyon"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mithrandi@lorien /tmp> pypy weakrefs.py | |
before disable: w() = <__main__.C object at 0x00007f5e52d41c58> | |
after del: w() = <__main__.C object at 0x00007f5e52d41c58> | |
after collect: w() = None | |
hi mom | |
after enable: w() = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def test_storeOverCollectedItem(self): | |
""" | |
If an item is replaced in the cache, the finalizer from the first item | |
does not remove the second item. | |
""" | |
o1 = Object(1) | |
self.cache.cache(42, o1) | |
gc.disable() | |
del o1 | |
gc.collect() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{-# LANGUAGE TemplateHaskell, Rank2Types, NoMonomorphismRestriction #-} | |
module Main where | |
import Control.Lens | |
import qualified Data.Map.Strict as M | |
data Deployment = Deployment | |
{ _deploymentName :: String | |
, _nodes :: [Node] | |
} deriving Show |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
findDataset :: Dataset -> Maybe String | |
findDataset (view datasetName -> Just name) = M.lookup name datasets | |
findDataset (view datasetName -> Nothing) = Nothing | |
update_dataset_id :: Dataset -> IO Dataset | |
update_dataset_id d = | |
case findDataset d of | |
Just did -> return $ d & datasetId ?~ did | |
Nothing -> (\did -> d & datasetId ?~ did) <$> toString <$> nextRandom |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/python | |
from os import environ | |
from socket import gethostname | |
from boto import connect_route53 | |
from boto.route53.record import ResourceRecordSets | |
IF_NAME = 'ppp4' | |
AWS_ACCESS_KEY = '...' | |
AWS_SECRET_KEY = '...' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
domain-needed | |
bogus-priv | |
resolv-file=/etc/ppp/resolv.conf | |
interface=eth0 | |
addn-hosts=/etc/ppp/peeraddr | |
domain=mithrandi.net | |
dhcp-range=set:eth0,10.0.0.100,10.0.0.200,24h | |
dhcp-range=::,constructor:eth0,ra-stateless,ra-names | |
dhcp-host=f4:6d:04:af:b7:f2,10.0.0.7,lorien,72h | |
dhcp-host=00:1b:21:04:a6:24,e0:cb:4e:e6:ff:5d,10.0.0.10,gondolin,72h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
from twisted.python.reflect import namedAny | |
template = """ | |
declareLegacyItem( | |
typeName=%r, | |
schemaVersion=%d, | |
attributes=dict( | |
%s)) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fetch(..., clock=None): | |
if clock is None: | |
from twisted.internet import reactor as clock | |
def handleResponse(response): | |
# ... | |
d = agent.request(method, url, Headers(h), body) | |
call = clock.callLater(timeout, d.cancel) | |
def cancelTimeout(result): |