This file contains hidden or 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 zope.interface import Interface | |
from twisted.python.components import proxyForInterface | |
class IResolver(Interface): | |
def callback(result): | |
pass | |
def errback(reason): | |
pass |
This file contains hidden or 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
import json | |
from klein import Klein | |
app = Klein() | |
_collections = {} | |
@app.route('/collections/') | |
def collections(request): |
This file contains hidden or 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
(klein)thomasina dreid:klein (master=)> python itemstore1.py | |
Map([<Rule '/items/' -> items>, | |
<Rule '/items/<name>/<__rest__>' (PUT) -> save_item_branch>, | |
<Rule '/items/<name>/<__rest__>' (HEAD, GET) -> get_item_branch>, | |
<Rule '/items/<name>/' (PUT) -> save_item>, | |
<Rule '/items/<name>/' (HEAD, GET) -> get_item>, | |
<Rule '/items/<__rest__>' -> items_branch>]) | |
2013-02-26 11:14:26-0800 [-] Log opened. | |
2013-02-26 11:14:26-0800 [-] Site starting on 8080 | |
2013-02-26 11:14:26-0800 [-] Starting factory <twisted.web.server.Site instance at 0x10ab59488> |
This file contains hidden or 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 klein import route | |
@route('/'): | |
def accept_some_work(request): | |
reactor.callLater(0, do_some_work, request) | |
return 'OK' |
This file contains hidden or 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
import sublime | |
import sublime_plugin | |
settings = sublime.load_settings('Preferences.sublime-settings') | |
orig_font_size = settings.get('base_font_size', settings.get('font_size')) | |
settings.set('base_font_size', orig_font_size) | |
sublime.save_settings('Preferences.sublime-settings') | |
class ZoomzeroCommand(sublime_plugin.WindowCommand): | |
def run(self): |
This file contains hidden or 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
-> if (('close' in connHeaders) or self._state != "QUIESCENT" or | |
(Pdb) connHeaders | |
['Close'] |
This file contains hidden or 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
""" | |
'22': | |
ufw.allow: | |
- enabled: true | |
- proto: tcp | |
- from: 127.0.0.1 | |
- to: any | |
""" |
This file contains hidden or 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
<doctype !html> | |
<script src="http://code.jquery.com/jquery-1.7.2.min.js"></script> | |
<script src="https://raw.github.com/mbostock/d3/master/d3.v2.min.js"></script> | |
<script src="https://raw.github.com/shutterstock/rickshaw/master/rickshaw.min.js"></script> | |
<div id="chart"></div> | |
<script> | |
var graph = new Rickshaw.Graph( { |
This file contains hidden or 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
>>> (foo, bar) = xrange(1) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
ValueError: need more than 1 value to unpack | |
>>> (foo, bar) = xrange(19) | |
Traceback (most recent call last): | |
File "<stdin>", line 1, in <module> | |
ValueError: too many values to unpack |
This file contains hidden or 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
""" | |
twistd -n web --class=hello.resource | |
""" | |
from klein import route, resource | |
@route('/') | |
def home(request): | |
return 'Hello, world!' |