Skip to content

Instantly share code, notes, and snippets.

View mitsuhiko's full-sized avatar
🖥️
What's happening

Armin Ronacher mitsuhiko

🖥️
What's happening
View GitHub Profile
from importlib.machinery import ModuleSpec, SourceFileLoader
from _frozen_importlib import _SpecMethods
path = '/tmp/test.py'
loader = SourceFileLoader('plugin_base', path)
spec = ModuleSpec(name='plugin_base', loader=loader)
mod = _SpecMethods(spec).create()
@mitsuhiko
mitsuhiko / bstrie
Last active December 14, 2015 06:18 — forked from bstrie/bstrie
fn main() {
let numbers = [1, 2, 3];
let keys = ["foo", "bar", "baz"];
for iter::zip(numbers, keys) |&number, &key| {
io::println(fmt!("%s => %d", key, number));
}
for iter::enumerate(keys) |&index, &key| {
io::println(fmt!("%u => %s", index, key));
fn main() {
match os::homedir() {
None => {
io::println("You have no home folder :-(");
}
Some(ref homedir) => {
io::println("Files in your home folder:");
for os::list_dir_path(homedir).each |path| {
match path.filename() {
Some(ref filename) => io::println(*filename),
Debugging middleware caught exception in streamed response at a point where response headers were already sent.
Traceback (most recent call last):
File "/home/max/.virtualenvs/flask/lib/python2.7/site-packages/werkzeug/wsgi.py", line 513, in next
return self._next()
File "/home/max/.virtualenvs/flask/lib/python2.7/site-packages/werkzeug/wrappers.py", line 829, in iter_encoded
for item in self.response:
File "/home/max/.virtualenvs/flask/lib/python2.7/site-packages/jinja2/environment.py", line 918, in generate
yield self.environment.handle_exception(exc_info, True)
File "/home/max/Projekte/flask-testing-stuff/templates/index.html", line 1, in top-level template code
{% extends "layout.html" %}
@mitsuhiko
mitsuhiko / flask-script-wtforms.py
Created March 19, 2012 14:54
flask-script with wtforms
import sys
from werkzeug.datastructures import ImmutableDict, MultiDict
from flask import request
from flaskext.script import Manager
from postfixmgmt import app, db, __version__
from postfixmgmt.forms import DomainAddForm
manager = Manager(app)