Remember what it was like building web apps before modern web frameworks? It was a lot of work! The structure and conventions that web frameworks gave us brought on a new level of rapid development, best practices, and collective understanding of the problem domain. Frameworks lowered the barrier to entry in building web sites and web applications.
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 gevent.pywsgi | |
| class UpgradableWSGIHandler(gevent.pywsgi.WSGIHandler): | |
| """Upgradable version of gevent.pywsgi.WSGIHandler class | |
| This is a drop-in replacement for gevent.pywsgi.WSGIHandler that supports | |
| protocol upgrades via WSGI environment. This means you can create upgraders | |
| as WSGI apps or WSGI middleware. | |
| If an HTTP request comes in that includes the Upgrade header, it will add |
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
| """A distributed group membership module | |
| This provides distributed group membership for easily building clustered | |
| applications with gevent. Using this in your app, you just provide the IP | |
| of another node in the cluster and it will receive the IPs of all nodes in | |
| the cluster. When a node joins or drops from the cluster, all other nodes find | |
| out immediately. | |
| The roster is managed by a leader. When you create a cluster, you tell the | |
| first node it is the leader (by simply pointing it to its own IP). As you |
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
| <?xml version="1.0" encoding="utf-8"?> | |
| <DieCutLabel Version="8.0" Units="twips"> | |
| <PaperOrientation>Landscape</PaperOrientation> | |
| <Id>Label</Id> | |
| <PaperName>30258 Diskette</PaperName> | |
| <DrawCommands> | |
| <RoundRectangle X="0" Y="0" Width="3060" Height="3960" Rx="270" Ry="270"/> | |
| </DrawCommands> | |
| <ObjectInfo> | |
| <ImageObject> |
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
| var badge = Raphael(200, 0, 225, 187); | |
| // Header | |
| var attrs = {'fill': '#f90', 'stroke': 'none', 'font-size': 11, 'font-family': 'helvetica'}; | |
| badge.rect(5, 3, 225, 14).attr(attrs); | |
| badge.circle(212, 8, 16).attr(attrs); | |
| var textAttrs = {'fill': '#fff', 'font-size': 11, 'font-family': 'helvetica', 'text-anchor': 'end'}; | |
| var text = badge.text(198, 9, "SuperHappyDevHouse"); | |
| text.attr(textAttrs); | |
| var num = badge.text(211, 9, "48"); |
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
| <html> | |
| <head> | |
| <style type="text/css"> | |
| svg { margin-left: -2000px; } | |
| </style> | |
| <script type="text/javascript" src="http://github.com/DmitryBaranovskiy/raphael/raw/master/raphael-min.js"></script> | |
| <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/rgbcolor.js"></script> | |
| <script type="text/javascript" src="http://canvg.googlecode.com/svn/trunk/canvg.js"></script> | |
| <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script> | |
| <script src="http://labelwriter.com/software/dls/sdk/js/DYMO.Label.Framework.latest.js" type="text/javascript" charset="UTF-8"> </script> |
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
| # writes host to a host file | |
| nc -l -p 9998 -c "./parse_http>/tmp/cgi;. /tmp/cgi>/dev/null && echo $HTTP_HOST > host" | |
| # pipemill the request body | |
| nc -l -p 9998 -c "./parse_http>/tmp/cgi;. /tmp/cgi | while read line; do something; done" | |
| # route on the path | |
| # uhh, well, sure, just use if on $HTTP_PATHINFO |
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
| def pseudo_code_example(): | |
| """Compare to the current implementation of start()""" | |
| class Service: | |
| def start(self, block_until_ready=True): | |
| self.state("start_services") | |
| for child in self._children: | |
| child.start(block_until_ready) | |
| self.state("services_started") | |
| ready = not self.do_start() | |
| if not ready and block_until_ready: |
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
| ws = new WebSocket("ws://localhost:8181/v1/metric/get") | |
| ws.onmessage = function (data) { console.log(data.data) } | |
| ws.send(JSON.stringify({metric: "biz.calls", aggregate: "sum", step: 20, start: "2012-02-15T01:05:00Z", stop: "2012-02-15T02:05:00Z"})) |
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
| class GlobalContext(object): | |
| """Context manager mixin for stackable singletons | |
| Use this mixin when a class has a global singleton set somewhere that can | |
| be temporarily set while in the context of an instance of that class:: | |
| class Foo(GlobalContext): | |
| instance = None # where we'll keep the singleton | |
| singleton_attr = (Foo, 'instance') # tell mixin where it is |