This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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". |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @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') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Euler where | |
import Control.Monad | |
import Data.List | |
import Data.Numbers.Primes | |
{- | |
https://projecteuler.net/problem=12 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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()) | |
} | |
}) |