Skip to content

Instantly share code, notes, and snippets.

View alecmce's full-sized avatar

Alec McEachran alecmce

View GitHub Profile
@alecmce
alecmce / deeperinjection.as
Created August 25, 2012 00:33
injecting data deeper?
// create a class that expects a MyData
public class SomeObject
{
[Inject]
public var data:MyData;
}
// configure a signal to trigger a command that contains a reference to that class
@alecmce
alecmce / tools.md
Created May 30, 2012 22:54
Tools For Interactive Software Development

Mac OS X Dev Setup

System Tools

  • iTerm: A better Terminal.
  • zsh: An even better Terminal.
  • Homebrew: Package manager.
  • git: Source control.
  • rvm: Ruby.
  • python: Python.
  • mamp: For managing localhost.
@alecmce
alecmce / nekoBitmapData.hx
Created January 31, 2012 04:37
Neko BitmapData Bongo Madness
// due to Neko's 31 bit integers and other nonsense, when you set a bitmap data's alpha value
// through Neko and then read it back out, the number ranges from -127 to 127 rather than from
// 0 to 255. Bongo madness. To unbongo, convert as follows:
var bitmapData = new BitmapData(1, 1, true, {rgb:0, a:0});
for (i in 0...256)
{
bitmapData.setPixel32(0, 0, {rgb:0xFFFFFF, a:i});
var alpha = bitmapData.getPixel32(0, 0).a;
var converted = alpha < 0 ? 255 + alpha : alpha;
@alecmce
alecmce / gist:1340845
Created November 5, 2011 00:09
cd to the front finder's location
# cdf: cd to the front finder's location
cdf ()
{
currFolderPath=$( /usr/bin/osascript <<" EOT"
tell application "Finder"
try
set currFolder to (folder of the front window as alias)
on error
set currFolder to (path to desktop folder as alias)
end try
@alecmce
alecmce / enum.hx
Created October 30, 2011 21:40
Haxe Enum Example
enum MyEnum
{
first;
second;
third(param:MyParam);
}
class MyClass
{
private var _state:MyEnum;
@alecmce
alecmce / describeInt.as
Created October 16, 2011 11:49
describeType to discover uint and int
package
{
import flash.display.Sprite;
import flash.utils.describeType;
[SWF(backgroundColor="#FFFFFF", frameRate="60", width="800", height="600")]
final public class Test extends Sprite
{
public function TestRunner()
@alecmce
alecmce / int-uint-madness.as
Created October 16, 2011 11:26
int/uint madness
package
{
import flash.display.Sprite;
[SWF(backgroundColor="#FFFFFF", frameRate="60", width="800", height="600")]
final public class Test extends Sprite
{
public function Test()
{
/**
* A ProcessStack is a utility that will wait run each process in order as added,
* running the subsequent process when it has completed
*/
public class InitProcess extends ProcessStack
{
public function InitProcess()
{
add(InitModelProcess);
@alecmce
alecmce / robotlegs_strategies.as
Created July 31, 2011 16:26
strategies for mapping values and executing commands in RobotLegs
1. github.com/robotlegs/robotlegs-framework/blob/master/src/org/robotlegs/base/CommandMap.as:
// only one mapping possible
mapValues();
command = createCommand(mapping);
unmapValues();
command.execute();
2. github.com/joelhooks/signals-extensions-CommandSignal/blob/master/src/org/robotlegs/base/SignalCommandMap.as:
@alecmce
alecmce / meh.as
Created July 18, 2011 09:02
one return per method
// a difference is not a difference unless it *makes* a difference
public function add(item:*):Boolean
{
if (contains(item))
return false;
push(item);
return true;
}