Skip to content

Instantly share code, notes, and snippets.

@nodename
nodename / gist:333660
Created March 16, 2010 04:55
modified version of David Wolever's ParameterizedRunner
// (c) 2010 David Wolever <david@wolever.net> and Verso Furniture Inc.
// See the bottom of this file for copyright details.
package flexunit4Param.testrunners
{
import flash.utils.getQualifiedClassName;
import flex.lang.reflect.Method;
import flex.lang.reflect.metadata.MetaDataAnnotation;
import flex.lang.reflect.metadata.MetaDataArgument;
@nodename
nodename / SwiftSuspendersFactoryInjectionExampleUsage.as
Created May 30, 2010 05:58
SwiftSuspendersFactoryInjectionExampleUsage.as
private function mapServiceClasses():void
{
for each (var serviceClass:Class in [ ServiceClassA, ServiceClassB, ServiceClassC ])
{
injector.mapFactory(serviceClass, prepareInstance(serviceClass));
}
function prepareInstance(serviceClass:Class):Function
{
return function():AbstractServiceClass
package
{
import flash.display.Graphics;
import flash.display.Shape;
import flash.display.Sprite;
import flash.geom.Point;
public class LogarithmicSpiralTest extends Sprite
{
public function LogarithmicSpiralTest()
package hype.framework.core {
import hype.framework.behavior.AbstractBehavior;
import hype.framework.trigger.AbstractTrigger;
/**
* Creates and manages pools of objects
*/
public class ObjectPool {
private var _classList:Array;
private var _max:uint;
@nodename
nodename / AOPTest.as
Created July 20, 2011 07:12
Interesting use of 'finally' to slip some code in before a function returns
// originally from Andy Shang http://bbs.9ria.com/viewthread.php?tid=47399
package
{
import flash.display.Sprite;
public class AOPTest extends Sprite
{
public function AOPTest()
{
@nodename
nodename / LoadAndTestCreatedClass .as
Created September 13, 2011 00:54
Load and test the Tuple<Point, Point, Point> class written to a swf by nodename/ClassGenerationTest
package
{
import flash.display.Loader;
import flash.display.Sprite;
import flash.events.Event;
import flash.geom.Point;
import flash.net.URLRequest;
import flash.system.ApplicationDomain;
import flash.system.LoaderContext;
import flash.utils.describeType;
@nodename
nodename / ModelSnippet.as
Created November 29, 2011 04:22
AS3 setter question: model.selectedMetric = x; where x already is the selectedMetric. The setter is NOT invoked. Why?
private var _selectedMetric:Metric;
[Bindable]
public function get selectedMetric():Metric
{
return _selectedMetric;
}
public function set selectedMetric(value:Metric):void
{
@nodename
nodename / test.clj
Created December 20, 2011 07:25
My first Clojure test! Create an image, save it as a PNG file with a custom metadata string, and read back the string from the file header
(import '(java.awt.image BufferedImage))
(import '(javax.imageio ImageIO IIOImage))
(import '(javax.imageio.stream FileImageOutputStream))
(import '(com.sun.imageio.plugins.png PNGMetadata PNGImageReader))
(import '(java.io ByteArrayOutputStream File))
;; See the following document for requirements
;; for upper- and lower-case letters in the four-letter chunk name:
;; http://en.wikipedia.org/wiki/Portable_Network_Graphics#.22Chunks.22_within_the_file
(def generator-chunk-name "gnTr")
@nodename
nodename / rovers.clj
Created February 6, 2012 07:00
Coding exercise #1: Mars Rovers
(ns rovers
(:use [clojure.string :only [split-lines]]))
(def *test-input*
"5 5
1 2 N
LMLMLMLMM
3 3 E
MMRMMRMRRM")
@nodename
nodename / account.clj
Created February 20, 2012 01:06
Coding Exercise #2: Fantasy Banking
(ns account
(:import [java.util Date]
[java.lang Math])
(:use [util]))
(def account-type [:checking :savings :money-market])
(def interest-rate (zipmap account-type [0.02 0.04 0.06]))
(def overdraft-charge (zipmap account-type [0.10 0.075 0.05]))