Skip to content

Instantly share code, notes, and snippets.

View groner's full-sized avatar

Kai Groner groner

  • Charlottesville, VA
View GitHub Profile
newpgrp() {
# Non-interactive shells don't have job control. Spawn an interactive shell
# to create a new process group. The inner non-interactive shell is there
# to avoid interactive side-effects later on.
$BASH --norc -ic '$BASH -c \"\$@\" -- "$@"' -- "$@"
}
# Notes on things that don't work:
# set -i
# You can't turn job control on this way
@groner
groner / annotatedmethod.py
Created February 18, 2015 18:29
Binding classes and instances with jeni injectors
'''This is my second attempt. It is much cleaner, except for the part that exposes the injector on bound classes and instances.
'''
from contextlib import suppress
from functools import wraps
from pprint import pprint
import jeni
@groner
groner / findclassannotations.py
Last active August 29, 2015 14:24
pip install astunparse; find . -name \*.py -exec python3 findclassannotations.py {} +
import argparse
import ast
import re
import sys
from astunparse import unparse as astunparse
from astunparse import dump as astdump
def main():
@groner
groner / terrain.py
Created August 10, 2010 13:11
Hooks for lettuce to run a test pylons server
'''Hooks for lettuce to run a test pylons server'''
import threading
from os import getcwd
import pylons.test
from paste.deploy.loadwsgi import loadapp
from paste.httpserver import serve
from paste.script.appinstall import SetupCommand
from sqlalchemy import create_engine
import db
def load_config():
return { 'dburi': 'sqlite:foobar.sqlite' }
if __name__ == '__main__':
config = load_config()
@groner
groner / persons.json
Created August 27, 2010 06:59
Filtering Select Experiment with angular.js
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ng="http://angularjs.org">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Filtering Select Experiment</title>
<style type="text/css" media="screen">
.rel {
position: relative;
}
@groner
groner / groups.yaml
Created September 3, 2010 01:37
YAML/SQLAlchemy fixture loader inspired by Chris Perkins' bootalchemy
%TAG !foo! tag:gronr.com,2010:
---
- Group:
- name: blues
- name: reds
- name: squares
@groner
groner / auto_relationing_declarative_meta.py
Created September 3, 2010 05:42
sa.ext.declarative extension to generate relations from foreign keys and __singular__/__plural__ declarations
from sqlalchemy import Column
from sqlalchemy.orm import RelationProperty, relation, backref, class_mapper
from sqlalchemy.ext.declarative import DeclarativeMeta, declarative_base
class AutoRelationingDeclarativeMeta(DeclarativeMeta):
r'''
>>> from sqlalchemy import Integer, ForeignKey, String
>>> Base = declarative_base(metaclass=AutoRelationingDeclarativeMeta)
@groner
groner / test-jinja.py
Created September 15, 2010 17:34
Simplest jinja2 setup
from jinja2.environment import Environment as Jinja2Environment
from jinja2.loaders import FileSystemLoader as Jinja2FileSystemLoader
def main():
env = Jinja2Environment(
loader=Jinja2FileSystemLoader('.'),
)
t = env.get_template('test.jinja')
@groner
groner / record.sh
Created September 21, 2010 19:57
gst pipeline used to record video at beSwarm 1
gst-launch-0.10 -v v4l2src device=/dev/video1 ! ffmpegcolorspace ! videoscale method=1 ! video/x-raw-yuv,width=1024,height=768 ! tee tee0. ! queue ! queue leaky=1 ! ffmpegcolorspace ! xvimagesink tee0. ! queue ! queue ! videoscale ! video/x-raw-yuv,width=1024,height=768 ! ffmpegcolorspace ! schroenc ! queue ! oggmux ! filesink location=beswarm.ogg