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> | |
| <script type="text/javascript" src="jquery-1.3.2.js"></script> | |
| </head> | |
| <body> | |
| Hey dudes. Here is the JSON console. This requires native JSON (though you could easily throw in the json2.js library to replace it) and the HTML5 Canvas element. I have only tested it on Firefox 3.5, but recent WebKit nightlies ought to work too. | |
| <p> | |
| <label for="url">URL: </label><input type="text" name="url" value="http://127.0.0.1:8000/1/" id="url"> <label for="request_method">Request Method: </label><input type="text" name="request_method" value="POST" id="request_method"> | |
| <br> |
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
| %% @author Jon Rosebaugh <jon@inklesspen.com> | |
| %% @copyright YYYY author. | |
| %% @doc TEMPLATE. | |
| -module(sessions). | |
| -author('Jon Rosebaugh <jon@inklesspen.com>'). | |
| -export([create_tables/0, load_session/1, save_session/1]). | |
| % These should probably be turned into arguments to the module at some point. |
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 decorator | |
| def multiplier(n): | |
| # will multiply the first incoming argument by n. | |
| def internal(fn, arg): | |
| return fn(arg*n) | |
| return decorator.decorator(internal) | |
| @multiplier(3) | |
| def foo(arg): |
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
| jon@euterpe:~$ port installed | |
| The following ports are currently installed: | |
| apr @1.3.8_0 (active) | |
| autoconf @2.64_2 (active) | |
| automake @1.11_0 (active) | |
| bash-completion @1.0_1 (active) | |
| bitstream-vera @1.10_0 (active) | |
| bzip2 @1.0.5_2+darwin (active) | |
| coreutils @7.5_0+with_default_names (active) | |
| curl @7.19.6_0 (active) |
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 mako.template import Template | |
| >>> templatetext = r""" | |
| ... Hello! | |
| ... % for x in [1,2,3,4,5]: | |
| ... ${x} \ | |
| ... % endfor | |
| ... | |
| ... This is indented. | |
| ... Whee | |
| ... Now back out. |
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 render_action(): | |
| # actually getting the controller and action names from the environment is left as an exercise for the reader | |
| controller = "foo" | |
| action = "bar" | |
| template_name = "%s/%s.mako" % (controller, action) | |
| return render_mako(template_name) |
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
| server { | |
| listen 80; | |
| server_name turnthepage.org www.turnthepage.org; | |
| root /domains/turnthepage; | |
| location / { | |
| error_page 503 /offline.html; | |
| return 503; | |
| } | |
| } |
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 session_mapper(scoped_session): | |
| def mapper(cls, *arg, **kw): | |
| cls.query = scoped_session.query_property() | |
| return sqla_mapper(cls, *arg, **kw) | |
| return mapper | |
| mapper = session_mapper(Session) | |
| # Then, you can do like Book.query.get(id) or User.query.filter_by(username="bar") |
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 paste.deploy import appconfig | |
| from MYAPP.config.environment import load_environment | |
| conf = appconfig('config:' + 'PATH_TO_DEVELOPMENT.INI') | |
| load_environment(conf.global_conf, conf.local_conf) | |
| from MYAPP.model import * |
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 logging | |
| from pylons import request, response, session, tmpl_context as c | |
| from pylons.controllers.util import abort, redirect_to | |
| from bar.lib.base import BaseController, render | |
| import bar.model as model | |
| log = logging.getLogger(__name__) |