[three]Bean
Hacking tw2 resource injection
Dec 13, 2011 | categories: python, toscawidgets, turbogears View CommentsTonight, VooDooNOFX was asking in IRC in #turbogears how to disable
the injection of jquery.js by tw2.jquery into her/his TG2 app. Using the
inject_resources=False
middleware config value wouldn't cut it,
since she/he wanted tw2 to inject all other resources, they were
loading jQuery via google CDN beforehand and tw2's injection was clobbering
their code.
I came up with the following hack to myapp/lib/base.py
which
will remove tw2.jquery.jquery_js from the list of resources tw2 would inject
into each page served by a TG2.1 app.
At the top of myapp/lib/base.py
import:
import tw2.core.core import tw2.jquery
and then replace:
return TGController.__call__(self, environ, start_response)
with the following:
stream = TGController.__call__(self, environ, start_response) # Disable the injection of tw2.jquery offending_link = tw2.jquery.jquery_js.req().link local = tw2.core.core.request_local() local['resources'] = [ r for r in local.get('resources', list()) if r.link != offending_link ] return stream
The two tricks to this are
- Simply knowing that tw2 resources register themselves with the 'request_local' object and that during the return-phase of the WSGI pipeline, the tw2 middleware refers to that list when injecting resources
- Figuring out where in a TG2 app's request flow to place the call to alter that object after all widgets that might register jquery have declared their resources but before the resources list is injected into the output stream.
We came out of it with a bug filed in the tw2 issue tracker so we can take care of it properly in the future.
skipping words in zsh
Nov 21, 2011 | categories: zsh View CommentsAbout a half year ago I started using zsh after having been introduced to the
GRML config. It boasts a ton of great
features including remote tab-completion over ssh under the hood (when trying to
remember a path for scp for instance). It's been great, but the one
thing I've been missing is that old word-skipping feature from bash; pressing
ctrl-left
and ctrl-right
is really nice.
After finding (in multiple places) cake that was
really a lie, I finally found it commented out at the bottom of a
random .zshrc. I added it to my ~/.zshrc.local
and am
finally in business.
bindkey '^[[1;5D' emacs-backward-word bindkey '^[[1;5C' emacs-forward-word
"chaplin-ize" - Fact: every Cinema studies department website is better with Charlie Chaplin
Nov 21, 2011 | categories: lulz, javascript View CommentsThis past week, work sent me to Seattle for Supercomputing 2011.
While there, I crashed with my sister, Doctor J, drank wine, did some dancing, and had a blast! On Friday night after the wine had set in, I tried explaining what it is I do. It's really just magic, but has to be described with words like python, and development. I showed off raptorizemw and soon enough, we were getting ready to chaplin-ize her department's new website!
Check it out at http://depts.washington.edu/mirg. The effect only triggers once in every three page loads (on average) so if it doesn't show, reload it a couple times.
python ansi2html makes taskwarrior fantas(k)tic
Oct 28, 2011 | categories: python, gtd View CommentsOver a year ago, I wrote a python module called ansi2html that takes colored ansi as input and produces colored, formatted html.
With it you can do something like the following:
$ ls --color=always | ansi2html > directory.html $ sudo tail /var/log/messages | ccze -A | ansi2html > logs.html
Much more recently I discovered taskwarrior, a command line todo list manager that rocks. It features the ability to produce burndown charts of your todos over time.
I use the following in a cronjob to produce an online version of my burndown chart.
$ task burndown | ansi2html | ssh me@web "cat > ~/static/burndown.html"
My regularly-updated chart is hosted on threebean.org.
If you come up with any neat uses for ansi2html, please let me know. I'd love to hear about them.
raptorizemw - Fact: Every WSGI app is better with a raptor.
Oct 03, 2011 | categories: python, lulz, pyramid, turbogears View CommentsIt's done. An over-engineered WSGI middleware component that adds a velociraptor to every page served. Fact: Every WSGI app is better with a raptor.
It's called raptorizemw (pronounced "awesome") and the only way to use it is in production.
« Previous Page -- Next Page »