Skip to content

Instantly share code, notes, and snippets.

View joelhooks's full-sized avatar
🍄

Joel Hooks joelhooks

🍄
View GitHub Profile
var machine = {
initial: 'state/STARTING',
states: [
{
name: 'state/STARTING',
transitions: [
{
action: 'action/completed/STARTED',
target: 'state/CONSTRUCTING' //name of the state to move to when event received
},
@joelhooks
joelhooks / pgessays.py
Created November 18, 2012 23:02 — forked from olasitarska/pgessays.py
Builds epub book out of Paul Graham's essays.
# -*- coding: utf-8 -*-
"""
Builds epub book out of Paul Graham's essays: http://paulgraham.com/articles.html
Author: Ola Sitarska <ola@sitarska.com>
This script requires python-epub-library: http://code.google.com/p/python-epub-builder/
"""
import re, ez_epub, urllib2, genshi
@joelhooks
joelhooks / AnotherBloatedDateTest.js
Created November 17, 2012 17:04
Custom Jasmine Matchers
it("convertToSplitDate should turen a Date into a split date", function() {
var date = new Date(2012, 10, 17),
splitDate = dateUtil.convertDateToSplitDate(date);
expect(splitDate).toBeDefined();
expect(splitDate.year).toBe(date.year);
expect(splitDate.month - 1).toBe(date.month);
expect(splitDate.day).toBe(date.day);
});
@joelhooks
joelhooks / sitemap_generator.rb
Created July 25, 2012 22:28
Upgrading to Octopress
fill_pages(site, urlset)
fill_legacy(urlset)
sitemap.add_element(urlset)
# File I/O: create sitemap.xml file and write out pretty-printed XML
unless File.exists?(site.dest)
FileUtils.mkdir_p(site.dest)
end
file = File.new(File.join(site.dest, SITEMAP_FILE_NAME), "w")
formatter = REXML::Formatters::Pretty.new(4)
@joelhooks
joelhooks / Class.js
Created July 24, 2012 22:59
Simple Javascript Inheritance
/* Simple JavaScript Inheritance
* By John Resig http://ejohn.org/blog/simple-javascript-inheritance/
* MIT Licensed.
*/
// Inspired by base2 and Prototype
(function(){
var initializing = false, fnTest = /xyz/.test(function(){xyz;}) ? /\b_super\b/ : /.*/;
// The base Class implementation (does nothing)
this.Class = function(){};
@joelhooks
joelhooks / thumbScroller.as
Created May 20, 2012 03:39
ever scrolling thumbnails
/**
* @private
*/
protected function mouseClickHandler(event:MouseEvent):void
{
selectedItem=item.data;
moveSelectedThumbToCenter();
}
@joelhooks
joelhooks / BaseActor.as
Created December 30, 2011 01:39
Robotlegs 2: Flickr Image Gallery Snippets
package robotlegs.bender.demos.imagegallery.base
{
import flash.events.Event;
import flash.events.IEventDispatcher;
/**
* Provides some common functionality for basic application classes (models and services)
*/
public class BaseActor
{
@joelhooks
joelhooks / darkworks.xml
Created December 6, 2011 21:01
DarkWorks for IDEA 11
<?xml version="1.0" encoding="UTF-8"?>
<scheme name="DarkWorks" version="1" parent_scheme="Default">
<option name="LINE_SPACING" value="1.0" />
<option name="EDITOR_FONT_SIZE" value="18" />
<option name="EDITOR_FONT_NAME" value="Anonymous Pro" />
<colors>
<option name="ANNOTATIONS_COLOR" value="58a0d6" />
<option name="CARET_COLOR" value="cccccc" />
<option name="CARET_ROW_COLOR" value="270f2f" />
<option name="GUTTER_BACKGROUND" value="f0f0f" />
@joelhooks
joelhooks / ISQLRunnerDelegate.as
Created July 6, 2011 02:36
Delegating at the Boundaries to Create a Testable Service
import com.probertson.data.QueuedStatement;
public interface ISQLRunnerDelegate
{
function get numConnections():int;
function get connectionErrorHandler():Function;
function set connectionErrorHandler(value:Function):void;
[Test]
public function toParamObject_returnsGenericObjectWithCorrectPropertyValues_objectIsEqual():void
{
var paramObject:Object;
var task:Task = new Task("testTask");
task.description = "task description";
task.statusId = 1;
task.taskId = 1;
paramObject = task.toParamObject();