Skip to content

Instantly share code, notes, and snippets.

View jbeard4's full-sized avatar

Jacob Beard jbeard4

View GitHub Profile
@jbeard4
jbeard4 / stack
Created March 14, 2013 01:08
sails stack trace
jacob@jacob-ThinkPad-W520:~/workspace/sails/sails$ npm test
> [email protected] test /home/jacob/workspace/sails/sails
> node test/start.js
debug: Running tests...
debug: Testing active record (aka waterline)...
-------------------------------------------------------
⋅⋅⋅✈⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅⋅
-------------------------------------------------------
@jbeard4
jbeard4 / collection.js
Last active December 14, 2015 21:09
Proof of concept to parse out dates in waterline before handling them off to the adapter.
//////////////////////////////////////////////////////////////////////
// collection.js
//
// This file is the prototype for collections defined using Waterline
// It contains the entry point for all DML/DQL methods (e.g. User.find())
// as well as some private members used internally, like sync()
//
// For the most part, methods in this file defer to adaper.js for
// their implementation, and the implementation here just validates the parameters.
//
@jbeard4
jbeard4 / extended description
Last active December 14, 2015 15:08
possible sails bug regarding policy chaining
This illustrates a possible bug in sails.
Steps to replicate. Submit a form once, then submit it again. The server will break.
This only occurs when using policy chaining, as rolling back the policy chaining (using only one policy per action) seems to resolve the issue.
Steps taken to resolve: I edited /sails/lib/scaffolds/controller.js:133:17 to change `res.json(values)` to `res.send(JSON.stringify(values))`. I did this, as I reasoned that this would avoid writing 'Content-Type : application/json' headers to the response. This changed the behaviour such that it caused the connection to hang on the second POST - a response would never be sent, and the connection would be held open.
I will attempt to create a reduced test case later.
var sm = (function(){
//declare your variables
var sharedData = {};
//this is your public interface to the statechart model. regular module pattern
return {
sharedData : sharedData,
model : {
states : [
{
@jbeard4
jbeard4 / Zotera.vb
Created February 9, 2013 23:42
Zotero.dot
Option Explicit
Private Const CP_UTF8 = 65001
Private Const WM_COPYDATA = &H4A
#If VBA7 Then
Type COPYDATASTRUCT
dwData As LongPtr
cbData As Long
lpData As LongPtr
@jbeard4
jbeard4 / scxml_join_example.xml
Last active April 13, 2018 01:24
To emulate a "join" transition in SCXML, you can use a single "default transition" (a transition without a trigger) originating from the parallel state, and use a cond attribute with "In()" predicates for each parallel substate you wish you join. You can find the definition of a join transition in the following paper: http://citeseerx.ist.psu.ed…
<scxml>
<parallel id="P">
<state id="A">
<state id="A-start">
<transition target="A-done" event="t"/>
</state>
<state id="A-done"/>
</state>
<state id="B">
<state id="B-start">
@jbeard4
jbeard4 / gist:4195449
Created December 3, 2012 14:49
SCXML with an explicit notion of timeout events
<scxml>
<state id="a">
<transition target="b" cc:timeout="1s"/>
</state>
<state id="b"/>
</scxml>
@jbeard4
jbeard4 / normalizeInitialStates.xsl
Created November 12, 2012 17:08
Normalize Initial States
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:s="http://www.w3.org/2005/07/scxml"
xmlns="http://www.w3.org/2005/07/scxml"
version="1.0">
<xsl:output method="xml"/>
<!-- identity transform -->
<xsl:template match="@*|node()">
<xsl:copy>
@jbeard4
jbeard4 / README.md
Created October 3, 2012 01:22 — forked from mbostock/.block
Epicyclic Gearing

From Wikipedia: Epicyclic gearing or planetary gearing is a gear system consisting of one or more outer gears, or planet gears, revolving about a central, or sun gear. … Epicyclic gearing systems also incorporate the use of an outer ring gear or annulus, which meshes with the planet gears.

Built with D3.js.

@jbeard4
jbeard4 / gnome-session-xmonad
Created August 4, 2012 18:37
This starts xmonad under Unity 2D
#! /bin/sh
xmonad &
xcompmgr &
exec gnome-session --session xmonad "$@"