Skip to content

Instantly share code, notes, and snippets.

View Stray's full-sized avatar

Stray Stray

  • Innerleithen, Scotland
View GitHub Profile
@Stray
Stray / fileMetrics.rb
Created January 8, 2011 18:38
Counts files, lines, words in a folder (by file extension) and then gives you a pure typing time analysis
require 'find'
if ARGV.length != 2
raise ArgumentError.new('Two arguments are required: path, extension')
end
path = ARGV[0]
extension = ARGV[1]
numFiles = 0
package com.client.app.feature.restricted.model {
public class AdminDataLoadingURLVarsFactorySupport extends AdminDataLoadingURLVarsFactory {
public function AdminDataLoadingURLVarsFactorySupport(keyIsGood:Boolean = true) {
if(keyIsGood){
fingerprintKey = new AdminKeyGoodSupport();
}
@Stray
Stray / CombinationGameIdeas.as
Created January 14, 2011 11:24
how I started out sketching the combination game
new CombinationGameBuilder()
.requireOneOf ( someItems )
.requireNoneOf ( someOtherItems )
// more rules as required
.build();
@Stray
Stray / TogglePanelPositionConditional.as
Created January 19, 2011 13:03
Toggle the position of a panel by conditional (for comparison with other approaches)
private var _isGoingUp:Boolean = false;
private function togglePanelPosition(e:MouseEvent):void
{
var yPos:Number = ON_STAGE_Y;
if(_isGoingUp)
{
yPos = OFF_STAGE_Y;
}
@Stray
Stray / TogglePanelPositionHandlers.as
Created January 19, 2011 13:11
Toggle the position of a panel by decoupled handlers (for comparison with other approaches)
private var _nextMotion:Function = revealPanel;
private function togglePanelPosition(e:MouseEvent):void
{
_nextMotion();
}
private function revealPanel():void
{
moveTo(ON_STAGE_Y);
@Stray
Stray / LinkedListPoint.as
Created January 19, 2011 13:31
An extension of Point for LinkedList implementation
package animation.geom
{
import flash.geom.Point;
public class LinkedListPoint extends Point
{
public var next:LinkedListPoint;
public function LinkedListPoint(x:Number, y:Number, nextPoint:LinkedListPoint)
{
@Stray
Stray / TogglePanelPositionLinkedList.as
Created January 19, 2011 13:41
Toggle the position of a panel by linked list (for comparison with other approaches)
private var _currentTargetPosition:LinkedListPoint;
private function createPositionTargets():void
{
var onPosition:LinkedListPoint = new LinkedListPoint(0, ON_STAGE_Y, null);
var offPosition:LinkedListPoint = new LinkedListPoint(0, OFF_STAGE_Y, onPosition);
onPosition.next = offPosition;
_currentTargetPosition = offPosition;
}
@Stray
Stray / InterestingEventTypesLookup.as
Created January 19, 2011 21:42
The actual service - map as a singleton and use getInstance to make it come to life
public class InterestingEventTypesLookup {
protected var _eventClassesByType:Dictionary;
public function get eventClassesByType():Dictionary
{
return _eventClassesByType ||= new Dictionary();
}
public function appendEventInterest(eventClass:Class, eventType:String):void
@Stray
Stray / YukkyConditionalCode.as
Created January 29, 2011 19:42
Look at those conditionals! Gross!
protected function selectedHandler(option:IBudgetGameOption, vo:BudgetGameOptionVO):void
{
enable(vo.enables);
disable(vo.disables);
dispatchUpdate(vo.cost, vo.productivity);
}
protected function enable(option:IBudgetGameOption):void
{
if(option != null)
@Stray
Stray / IBudgetGameOption1.as
Created January 29, 2011 19:52
First version of the BudgetGameOption interface
public interface IBudgetGameOption
{
function select():void;
function deselect():void;
function enable():void;
function disable():void;