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
| // test utils | |
| function assert(desc, b) { | |
| document.write("**" + desc + "</br>" ); | |
| document.write(b ? "OK": "FAIL"); | |
| document.write("</br>"); | |
| document.write("</br>"); | |
| } | |
| function test(desc, fn) { | |
| assert(desc, fn()) |
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> | |
| <html lang=en> | |
| <head> | |
| <title>quick'n'dirty js testing framework</title> | |
| <meta charset=utf-8> | |
| <style type="text/css" media="screen"> | |
| h1{ font: 1.5em Helvetica; } | |
| p { font: .9em courier; padding: .5em 1em; margin: 0;} | |
| .result { margin-top: 1px; } |
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 re | |
| from operator import add, mul, sub | |
| import sys | |
| ops = {'=': add, '@': sub, '#': mul } | |
| r = '\^(.)\s*(\-?\d+)\s*(\-?\d+)\$' | |
| def e(g): | |
| g = g.groups() |
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
| timing_logger = logging.getLogger('something') | |
| @contextmanager | |
| def timing(name): | |
| t1 = datetime.now() | |
| try: | |
| yield | |
| finally: | |
| t1 = datetime.now() - t1 | |
| t1 = t1.seconds + t1.microseconds/1e6 |
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 re | |
| def template(text, vars): | |
| def _t(v): | |
| v = v.groups()[0] | |
| return vars.get(v, '') | |
| return re.sub('\{([^\}]*)\}', _t, text) | |
| print template("hello, my name is {name}", {'name': 'javi'}) | |
| # please, do not use this code, instead you could use http://docs.python.org/library/string.html#template-strings |
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
| virtualenv --no-site-packages . | |
| source bin/activate | |
| bin/pip install tornado | |
| bin/pip freeze > requirements.txt | |
| mkdir app | |
| git init | |
| cat >.gitignore <<EOF | |
| bin/ | |
| include/ | |
| lib/ |
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
| 0 171556606.0 | |
| 1 10728346.0 | |
| 2 5160568.0 | |
| 3 2201743.0 | |
| 4 934465.0 | |
| 5 492517.0 | |
| 6 626750.0 | |
| 7 1387458.0 | |
| 8 5171130.0 | |
| 9 1478714.0 |
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 flask import abort, request, Response | |
| class Resource(object): | |
| """ CRUD resource """ | |
| def create(self): self._not_implemented() | |
| def list(self): self._not_implemented() | |
| def get(self, id): self._not_implemented() | |
| def delete(self, id): self._not_implemented() |
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> | |
| <html> | |
| <head> | |
| <title>G</title> | |
| <meta charset="utf-8" /> | |
| </head> | |
| <body> | |
| <!-- <canvas id="c"></canvas> --> | |
| <script> | |
| var G = function(init, loop, options) { |
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 has('gui_running') | |
| set background=light | |
| colorscheme solarized | |
| set guifont=Monaco:h14 | |
| set guioptions-=r | |
| set guioptions-=L | |
| set guioptions-=T | |
| set nu | |
| noremap <Leader>f <ESC>:set invfu<CR> | |
| set fuopt+=maxhorz |