Skip to content

Instantly share code, notes, and snippets.

View seanhess's full-sized avatar

Sean Hess seanhess

View GitHub Profile
@seanhess
seanhess / index.jsx
Last active August 29, 2015 14:16
Cursor Proposal
const React = window.React = require('react')
const {map, append, partial, curry, compose} = require('ramda')
const shortid = require('shortid')
// STATE --------------------------------------------------------
// returns a state object, and automatically creates sub-cursors
// state.items = cursor to items
// state.items[0] = cursor to items[0].
@seanhess
seanhess / average.js
Created January 23, 2015 21:35
Stuff we did Allan
function averagePricePaid(array, inv) {
var totalCost = 0;
var totalShares = 0;
for(var i = 0; i < array.length; i++) {
totalCost += array[i].cost;
totalShares += array[i].shares;
}
inv.costBasis = totalCost/totalShares;
return(inv.costBasis);
@seanhess
seanhess / example.js
Created January 8, 2015 18:39
Jerry Example Forms
var SavingFocusingInput = component(function (props) {
function onChange(e) {
props.cursor.cursor('text').update(() => e.currentTarget.value)
}
return React.DOM.input({ value: props.cursor.get('text'), onChange: onChange });
});
@seanhess
seanhess / index.html
Created December 18, 2014 16:36
Omniscient React Router
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>React Omniscient</title>
</head>
<body>
<div id="content"></div>
<script src="bundle.js"></script>
</body>
</html>
@seanhess
seanhess / Orion.txt
Created December 6, 2014 04:46
Orion nasa
"The future is now" says NASA
"Our program is way more badass-er.
We'll colonize Mars,
Before self driving cars.
But first we must conquer this aste....roid".
@seanhess
seanhess / omni-react.js
Created November 25, 2014 19:37
omniscient with react-router and immstruct
/**
* @jsx React.DOM
*/
window.React = require('react/addons');
var Immutable = require('immutable')
var component = require('omniscient')
var immstruct = require('immstruct')
var Router = require('react-router')
@seanhess
seanhess / sierpinksi.hs
Created November 10, 2014 20:21
Sierpinski
-- https://www.hackerrank.com/challenges/functions-and-fractals-sierpinski-triangles
import Data.List
import Data.Monoid
data Pixel = Pixel | Blank deriving (Show)
instance Monoid Pixel where
mempty = Blank
mappend Blank Blank = Blank
-- https://stackoverflow.com/questions/1651351/clojure-call-a-function-for-each-element-in-a-vector-with-it-index/1651736#1651736
-- (map #(setCell 0 %1 %2) (iterate inc 0) data)
words = ["Hello", "World", "Test", "This"]
-- here's a direct translation
setCells words = map (\(i, word) -> setCell 0 i word) $ zip [1..] words
-- here are some different ways you could write it
setCells = map toCell . zip [1..]
where
@seanhess
seanhess / Euler12.hs
Last active August 29, 2015 14:08
Euler 12
module Euler where
import Control.Monad
import Data.List
import Data.Numbers.Primes
{-
https://projecteuler.net/problem=12
// structure is an immstruct
// App is an omniscient component
var Main = page(structure, function(params) {
loadSomething(params.id, structure.cursor())
return function() {
return App(structure.cursor())
}
})