Skip to content

Instantly share code, notes, and snippets.

View L8D's full-sized avatar

Tenor L8D

View GitHub Profile
@L8D
L8D / things.js
Last active August 29, 2015 14:06
things
function Tuple(a, b, c, d, e, f, g) {
function tuplable(transformer) {
return transformer(a, b, c, d, e, f, g);
};
tuplable.toString = function() {
return 'Tuple (' + [a, b, c, d, e, f, g].filter(function(item) {
return item != null;
}).join(', ') + ')';
};
@L8D
L8D / data.js
Last active August 29, 2015 14:06
The 'Data' monad/tuple thingy in JavaScript
var Data = function(first, second, third, fourth, fifth, sixth, seventh) {
return function(iterator) {
return iterator(first, second, third, fourth, fifth, sixth, seventh);
};
};
// or more elegantly
var Data = function(a, b, c, d, e, f, g) {
return function(fn) {
return fn(a, b, c, e, f, g);
@L8D
L8D / rl.js
Created September 13, 2014 06:52
RL Interpreter in JavaScript...Because FUN
(function(root, factory) {
if (typeof define === 'function') {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.RL = factory();
}
})(this, function() {
var run = function(code, stack, dict) {
@L8D
L8D / rl.hs
Last active August 29, 2015 14:06
Function{al,ing} RL interpreter written in Haskell
{-# LANGUAGE LambdaCase #-}
{-# LANGUAGE TupleSections #-}
import System.Environment (getArgs)
import System.Exit (ExitCode(..), exitWith)
import Data.Maybe (listToMaybe, fromMaybe)
import Data.Fixed (mod', div')
showDouble :: Double -> String
showDouble n = if n `mod'` 1 == 0 then show (n `div'` 1) else show n
@L8D
L8D / thing.hs
Last active August 29, 2015 14:06
-- How I should be able to define a model
tasks :: [a] -> Either a a -> [a]
tasks ts = either (:ts) (`delete` ts)
-- How I should be able to define an event stream
eventStream = scanl tasks . map (Left . getValue . getTarget) . filter ((== 13) . getWhich)
main = someWayToSelectElementAndMakeEventStreams "#input-box" "keydown"
>>= eventStream
>>= mapM renderMyList
@L8D
L8D / zync.js
Last active August 29, 2015 14:06
;(function(root, factory) {
if (typeof define === 'function') {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.Zync = root.$ = factory();
}
})(this, function() {
function fromMarkup(markup) {
@L8D
L8D / zt.js
Last active August 29, 2015 14:05
(function(root, factory) {
if (typeof define === 'function' && define.amd) {
define(zt);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.zt = factory();
}
})(this, function() {
var zt = function(tag) {
<p>
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec fermentum
nec ante eget suscipit. Nullam gravida viverra quam a maximus. Proin nunc
massa, auctor id arcu a, imperdiet placerat tortor. Maecenas eget tristique
odio. Nullam fermentum orci erat, sed ultrices nunc volutpat sit amet. Duis
id nunc nisi. Morbi placerat eros in pretium dignissim. Mauris lacinia,
diam vitae euismod cursus, ligula ex vehicula nulla, vitae convallis nibh
sem ac velit. Nulla facilisi. Ut consectetur id mauris nec fermentum. Cras
nec cursus justo. Donec tempus quam nunc, sed faucibus lacus vulputate vel.
Integer egestas ex ut neque tristique dictum. Phasellus ut nulla mauris.
@L8D
L8D / vimrc
Last active August 29, 2015 14:05
" setup NERDTree button
nnoremap <silent> <leader>m :NERDTreeToggle<enter>
" map ctrl+hjkl to c-w movements
map <C-h> <C-w>h
map <C-j> <C-w>j
map <C-k> <C-w>k
map <C-l> <C-w>l
" pathogen stuff
@L8D
L8D / gist:7911fbaf0ad1b5642cd5
Last active August 29, 2015 14:01
Some MTG rules-enforced environment simulator concept prototypes
import qualified Data.Set as S
data Color
= White
| Blue
| Black
| Red
| Green
deriving (Enum, Eq, Ord)