Skip to content

Instantly share code, notes, and snippets.

View jbeard4's full-sized avatar

Jacob Beard jbeard4

View GitHub Profile
<scxml initial="p">
<parallel id="p">
<history id="h">
<transition target="A.2 B.2"/>
</history>
<state id="A" initial="A.1">
<state id="A.1"/>
@jbeard4
jbeard4 / gist:849856
Created March 1, 2011 20:44
procedure addStatesToEnter
procedure addStatesToEnter(s,root,statesToEnter,statesForDefaultEntry):
if isHistoryState(s):
if historyValue[s.id]:
for s0 in historyValue[s.id]:
addStatesToEnter(s0,getParent(s),statesToEnter,statesForDefaultEntry)
else:
for t in s.transition:
for s0 in getTargetStates(t.target):
addStatesToEnter(s0,getParent(s),statesToEnter,statesForDefaultEntry)
else:
@jbeard4
jbeard4 / gist:850186
Created March 2, 2011 00:11
test case 1
<scxml xmlns="http://www.w3.org/2005/07/scxml" profile="ecmascript" version="1.0" name="scxmlRoot">
<initial>
<transition target="A2 B2"/>
</initial>
<parallel id="P">
<state id="A" initial="A1">
<state id="A1"/>
@jbeard4
jbeard4 / gist:850188
Created March 2, 2011 00:12
test case 2
<scxml xmlns="http://www.w3.org/2005/07/scxml" profile="ecmascript" version="1.0" name="scxmlRoot">
<initial>
<transition target="P"/>
</initial>
<parallel id="P">
<history id="H" type="deep"/>
<state id="A" initial="A1">
<state id="A1">
@jbeard4
jbeard4 / gist:853745
Created March 3, 2011 22:23
enterStates and addStatesToEnter specification
procedure enterStates(enabledTransitions):
statesToEnter = new OrderedSet()
statesForDefaultEntry = new OrderedSet()
for t in enabledTransitions:
if t.target:
LCA = findLCA([t.source].append(getTargetStates(t.target)))
addStatesToEnter(getTargetStates(t.target),LCA,statesToEnter,statesForDefaultEntry)
if isParallelState(LCA):
@jbeard4
jbeard4 / gist:853759
Created March 3, 2011 22:29
revised scxml step algorithm patch
From 5aaf3c0a528f9863b19c7a1d99ae8a48fbc8ce64 Mon Sep 17 00:00:00 2001
From: jbeard4 <jbeard4@cs.mcgill.ca>
Date: Thu, 3 Mar 2011 14:24:31 -0800
Subject: [PATCH]
---
gistfile1.py | 29 +++++++++++++++++++++++++----
1 files changed, 25 insertions(+), 4 deletions(-)
diff --git a/gistfile1.py b/gistfile1.py
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en" id="facebook" class=" no_js">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-language" content="en" />
<script type="text/javascript">
//<![CDATA[
CavalryLogger=false;window._is_quickling_index=""; window._script_path = "\/authorize.php";window._EagleEyeSeed="cmm4";__rm = {};
//]]>
@jbeard4
jbeard4 / initial-state.xml
Created February 23, 2012 14:45
simple initial scxml
<?xml version="1.0" encoding="UTF-8"?>
<scxml
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0">
<initial>
<transition target="a"/>
</initial>
<state id="a"></state>

Javascript and prototypal inheritance

curl -s https://raw.github.com/gist/2467484/oop.js | node

import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.Function;
import org.mozilla.javascript.Context;
import org.mozilla.javascript.ScriptableObject;
import test.Reduced;
class TestReduced {
public static void main(String[] args){
Reduced reduced = new Reduced();