Skip to content

Instantly share code, notes, and snippets.

@moschlar
moschlar / test_site.py
Created June 14, 2012 14:34
Test multiple sites
from sauce.tests import TestController
__all__ = ['TestSite']
class TestSite(TestController):
sites = ['/', '/about', '/contact']
def _do_site(self, site):
response = self.app.get(site)
@moschlar
moschlar / types.py
Created August 14, 2012 08:49
Get file mime type with python-magic
#!/usr/bin/env python2
import os, sys
from magic import Magic
from collections import defaultdict
from itertools import groupby
from pprint import pprint
m = Magic(mime=True)
me = Magic(mime_encoding=True)
<section id="extras" class="body">
% if 'blogroll' in conf:
<div class="blogroll">
<h2>blogroll</h2>
<ul>
% for name, link, tooltip in conf.blogroll:
% if not link:
<li><p>${ name or '&nbsp;' }</p></li>
% else:
<li><a href="${ link or '#' }" rel="external" title="${ tooltip or '' }">${ name or '&nbsp;' }</a></li>
@moschlar
moschlar / test_quick.py
Created September 27, 2012 22:02
Badass speedup of simple tg site tests
# -*- coding: utf-8 -*-
"""
This test module will run setUp and tearDown only *once* for all test cases in this module.
This is very convenient for users who want to just test multiple urls whether they are reachable and respond with the correct http response code.
"""
import logging
log = logging.getLogger(__name__)
from os import path
@moschlar
moschlar / index.py
Created November 23, 2012 15:01
Index page for comparing different JavaScript-based source code editor widgets
#!/usr/bin/env python
import tw2.core as twc
import tw2.forms as twf
import tw2.bootstrap.forms as twb
import tw2.devtools as twd
#https://github.com/moschlar/tw2.ace
import tw2.ace
#https://github.com/moschlar/tw2.codemirror
import tw2.codemirror
@moschlar
moschlar / edit.html
Created December 7, 2012 22:45
Generated HTML
<script type="text/javascript">ace.require("ace/ext/textarea").transformTextarea(document.getElementById("source")).getSession().setMode("ace/mode/java")</script>
<script type="text/javascript">ace.require("ace/ext/textarea").transformTextarea(document.getElementById("source")).getSession().setMode("ace/mode/java").getSession().setMode("ace/mode/java")</script>
import os
import tw2.core as twc
import tw2.forms as twf
ace_js = twc.JSLink(
modname=__name__,
filename='static/ace/ace.js',
edit=twc.js_function('ace.edit'),
require=twc.js_function('ace.require'),
# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $
EAPI=4
inherit eutils latex-package
# All acroread related stuff is gracefully stolen from app-text/acroread/acroread-9.5.1-r1.ebuild
ACROREAD_LICENSE="Adobe"
@moschlar
moschlar / resume.c
Created January 9, 2013 23:18 — forked from klange/_.md
#include <stdio.h>
#include <time.h>
/* TODO: resume.h */
typedef struct {
char * company;
char * location;
char * title;
main = putStrLn "Hello, World!"