Skip to content

Instantly share code, notes, and snippets.

@eugeniop
eugeniop / gist:2939379
Created June 16, 2012 00:38
StateMachine
StateMachine<InputEvent,Data> sm = new StateMachine<InputEvent,Data>();
sm.AddState("ONE", null)
.HandleEvent<InputOne>("ONE", (i, ctx, n) => {
Assert.AreEqual(1, i.Id);
Assert.AreEqual("ONE", n);
return n;
},
"Message 1 1")
.HandleEvent<InputTwo>("TWO", (i, ctx, n) => {
@eugeniop
eugeniop / State.cs
Created August 27, 2012 05:25
A simple state machine
public class State<S, E>
{
private readonly List<StateEntry<S,E>> entries;
public State()
{
this.entries = new List<StateEntry<S,E>>();
}
public StateEntry<S,E> When(Func<E, bool> selector)
@eugeniop
eugeniop / example.js
Created November 22, 2012 00:09
A simple sattemachine
var stateMachine = require('./statemachine');
var EventOne = function(event)
{
return event == 'one';
}
var EventTwo = function(event)
{
return event == 'two';
@eugeniop
eugeniop / gist:5608627
Last active December 17, 2015 12:19 — forked from glennblock/gist:5608543
Comments on Glenn's article on REST
_REST_, or Representational State Transfer is probably one of the most misunderstood terms in Web API development today. Where REST is misunderstood is that most people use REST as synonymous with anything that is easy to access over HTTP and forget about the constraints completely.
The term's roots are from Roy Fielding's previously mentioned dissertation on network based architecture (http://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm). In it, Roy describes REST as an architectural style for distributed hypermedia systems. What he is saying is that REST is not a technology, it is not a framework, and it is not a design pattern. It is a style. There is no "One True Way" to do REST and as a result, many flavours of RESTful systems. What they have in common however, and most importantly, is that RESTful systems manifest iteself in a set of constraints: X, Y, Z.
The other part of the misunderstanding is that you MUST build a RESTful system. This is also not the case. The RESTful constrai
@eugeniop
eugeniop / gist:6664806
Created September 22, 2013 23:18
Simolpe sample suing the "headless" Login Widget.
<html>
<head></head>
<body>
<h1>Headless</h1>
<% include header %>
<br><br>
<h3>Sign In</h3>
<hr />
<div class="signin">
@eugeniop
eugeniop / CPCLLabelFormatter
Created November 22, 2013 05:29
Zebra Printer
using System;
using System.Collections.Generic;
using System.Text;
using mOrders.Terminal.Infrastructure;
using mOrders.Terminal.Store;
namespace mOrders.Terminal.Services
{
public class CPCLLabelFormatter
{
<%@ Language="VBScript" %>
<script language="JScript" runat="server" src='json2.js'></script>
<%
CLIENT_ID = "PLACE YOUR AUTH0 CLIENTID HERE"
CLIENT_SECRET = "PLACE YOUR AUTH0 CLIENT SECRET HERE"
REDIRECT_URI = "http://localhost/Auth0ASP/callback.asp"
AUTHORIZATION_CODE = Request.querystring( "code" )
@eugeniop
eugeniop / app.css
Created May 29, 2014 05:09
Pusher Auth0
body{
padding: 20px;
background: #f1f1f1;
}
h1,h2,h3{
font-weight: 100;
}
.btn{
@eugeniop
eugeniop / app.js
Created September 1, 2014 22:23
Generate SAS Token for Azure Service Bus & send to Queue
var crypto = require('crypto');
var util = require('util');
var request = require('request');
var sbNamespace = '{YOUR NAMESPACE}';
var sbEntityPath = '{YOUR QUEUE}';
var sharedAccessKey = 'LBgdFoE........lFyvW4=';
var sharedAccessKeyName = '{POLICY NAME}';
var sas = getSASToken(sbNamespace, sbEntityPath, sharedAccessKeyName, sharedAccessKey);
@eugeniop
eugeniop / configure.sh
Created September 2, 2014 03:49
configure.sh
#!/bin/bash
set -e
wget -qO - https://gist.github.com/jfromaniello/1672b30342ee0eff5ee6/raw/update.sh > /root/update.sh
chmod +x /root/update.sh
wget -qO - https://gist.github.com/jfromaniello/1672b30342ee0eff5ee6/raw/update_config.sh > /root/update_config.sh
chmod +x /root/update_config.sh