Skip to content

Instantly share code, notes, and snippets.

View nmorse's full-sized avatar
🔮

Nate Morse nmorse

🔮
View GitHub Profile
@nmorse
nmorse / nowjs_node-static.template.js
Created April 6, 2012 19:49
a template for combining: Nowjs and node-static
var nowjs = require("now");
var everyone;
var node_static = require('node-static');
//
// Create a node-static server instance to serve the './client' folder
//
var node_static_file = new(node_static.Server)('./client');
var server = require('http').createServer(function (req, res) {
req.addListener('end', function () {
@nmorse
nmorse / server_main.js
Created July 17, 2012 17:10
basic nowJS on connect and disconnect methods
var node_static = require('node-static');
var node_static_file = new(node_static.Server)('./client');
var http = require('http'),
players = {},
server = http.createServer(function(req, res) {
// static file server
req.addListener('end', function () {
node_static_file.serve(req, res);
});
}).listen(80);
@nmorse
nmorse / form.json
Last active August 29, 2015 14:11
angular-schema-form_proj
[
{
"type": "help",
"helpvalue": "<h4>Tabbed Array Example</h4><p>Tab arrays can have tabs to the left, top or right.</p>"
},
{
"key": "fe",
"type": "tabarray",
"add": "New",
"remove": "Delete",
import Color exposing (..)
import Graphics.Collage exposing (..)
import Graphics.Element exposing (..)
dots = 50
main : Element
main =
collage 150 150 (List.map shape [0..dots-1])
import Graphics.Element exposing (show)
graph = {nodes=[{id=1, name="test1"}, {id=2, name="test2"}],
edges=[{from=2, to=1, e_type="get"}, {from=2, to=1, e_type="set"}, {from=1, to=2, e_type="get"}]}
main =
show (edgesTo graph.edges 1, edgesToOf graph.edges 1 "get")
edgesTo : List { a | to : Int } -> Int -> Int
edgesTo list nodeId =
case list of
<!DOCTYPE html>
<html>
<body>
<p>Close this window, press F5 or click on the link below to invoke the beforeunload event.</p>
<p>The problem is that we cannot tell the difference between unload and reload</p>
<a href="http://www.google.com">Click here to go to google.com</a>
<div id="count">0</div>
<script>
@nmorse
nmorse / basic.cycle.js
Last active May 15, 2017 01:14
tried cycle.js for the first time (on the http://widdersh.in/tricycle/ site) starting with the basic demo. I updated the single increment example to add a subtract button, fun to be functional in js and use streams easily.
import {run} from '@cycle/xstream-run';
import {makeDOMDriver, div, button} from '@cycle/dom';
import _ from 'lodash';
import xs from 'xstream';
function main ({DOM}) {
const add$ = DOM
.select('.add')
.events('click')
import {run} from '@cycle/xstream-run';
import {makeDOMDriver, div, button} from '@cycle/dom';
//import _ from 'lodash';
import sampleCombine from 'xstream/extra/sampleCombine'
import xs from 'xstream';
function main ({DOM}) {
const inc = (c) => c+1;
@nmorse
nmorse / map.alpha.pounce
Last active September 26, 2018 20:13
Pounce needs a map combinator, working on it here...
// a definition of 'map'
{
local-words:{
map-repeat: [dup 0 > [1 - swap dup dip2 swap map-repeat] [drop drop drop r get [drop] dip] if-else ]
map-package: [{} swap f set swap o set [] r set]
}
fn:[map-package
[o get dup str-length 0 > [pop [f get] dip2 2 bubble-up apply [o set] dip [r get ] dip prepend r set] if]
[dup [apply] dip] [o get str-length] dip2 2 bubble-up map-repeat
]
@nmorse
nmorse / update.pounce
Created October 9, 2018 16:38
Pounce Update a map value
# simply updates a poperty in a map
[[dup] dip [get] dip2 dip set] [update] def
{u:6} u [1 +] update
{x:1 y:2} x [1 +] update y [1 -] update