Skip to content

Instantly share code, notes, and snippets.

@mattupstate
mattupstate / golden_ticket.md
Created August 22, 2011 22:29 — forked from voodootikigod/gist:1155790
PyCodeConf Ticket Give-away
@mattupstate
mattupstate / controller.py
Created August 18, 2011 22:43
Simple way of implementing before and after filters in a web.py app
def before_filter(*args, **kwargs):
print "before"
def after_filter(*args, **kwargs):
print "after"
class Controller(object)
@RequestFilter(before=[before_filter], after=[after_filter])
def GET(self):
return "Hello!"
@mattupstate
mattupstate / convert_all_to_south.py
Created July 24, 2011 20:12
Django management command to convert all your apps to use South migrations
import settings
from django.core.management.base import BaseCommand
from subprocess import call
class Command(BaseCommand):
def _is_project_app(self, app_name):
return not 'django' in app_name and not 'south' in app_name
def handle(self, *args, **options):
package net.nobien.cloudfoundry.example.config.database
import java.net.UnknownHostException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@mattupstate
mattupstate / cloud-context-config
Created April 19, 2011 14:47
Easily get your cloud environment properties in your Spring context initializer
package net.nobien.cloudfoundry.example.config;
import java.util.Properties;
import org.cloudfoundry.runtime.env.CloudEnvironment;
import org.cloudfoundry.runtime.env.CloudEnvironmentPropertiesFactoryBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.ApplicationContextInitializer;
import org.springframework.core.env.ConfigurableEnvironment;
package
{
import flash.display.DisplayObject;
import flash.utils.getQualifiedClassName;
import nl.demonsters.debugger.MonsterDebugger;
/**
* The Out class is the application's logger console proxy. All messages are sent to a running
* instance of De MonsterDebugger.
* @see http://www.demonsterdebugger.com/
<!-- Compiles the unit tests and runs the FlexUnit task to analyze the results. -->
<target name="run-test" depends="init,run-flexunit">
<if>
<equals arg1="${flexunit.failed}" arg2="true" />
<then>
<fail message="Unit tests failed." />
</then>
</if>
</target>
<!-- Compiles the SWF and launches a browser for debugging. -->
<target name="run-debug" depends="compile-swf">
<if>
<equals arg1="${os.name}" arg2="Mac OS X" />
<then>
<exec executable="open" spawn="true">
<arg line="-a ${env.DEFAULT_BROWSER} ${debug.compile.output}" />
</exec>
</then>
<else>
<!-- Runs the FlexUnit task on the compiled test output. -->
<target name="run-flexunit" depends="compile-test">
<flexunit swf="${test.compile.output}"
toDir="${test.bin.dir}"
haltonfailure="false"
verbose="true"
localTrusted="true"
failureproperty="flexunit.failed"
timeout="5000" />
</target>
<!-- Compiles the project into a SWF. -->
<target name="compile-swf" depends="init,clean-bin">
<java jar="${env.FLEX_HOME}/lib/mxmlc.jar" dir="${env.FLEX_HOME}/frameworks" fork="true" failonerror="true">
<arg value="${debug.compile.target}" />
<arg value="-output=${debug.compile.output}" />
<arg value="-source-path=${src.dir}" />
<arg value="-library-path+=${lib.dir}" />
<arg value="-static-link-runtime-shared-libraries=true" />
<arg value="-incremental=true" />
<arg value="-verbose-stacktraces=true" />