Skip to content

Instantly share code, notes, and snippets.

@L8D
L8D / either.js
Created Oct 22, 2014
Fantasy-land compliant and JIT-optimizable Either
View either.js
// Copyright (c) 2014 Tenor Biel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
@L8D
L8D / maybe.js
Created Oct 22, 2014
Fantasy-land compliant and JIT-optimizable Maybe
View maybe.js
// Copyright (c) 2014 Tenor Biel
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
View Rl.hs
{-# LANGUAGE TemplateHaskell #-}
module Rl where
import Control.Monad.Trans.State
import Control.Lens
import Text.Read (readMaybe)
import qualified Data.Map as M
import Control.Monad.IO.Class
import Control.Applicative (liftA2)
View spec-zvi
% comments are like this
% outside of operator precedence, the only special
% syntax is ':-' and ':='. ':=' is used for a type
% annotation. Types are just additional predicate
% calls, but they are restricted to not using IO
% values or ambigious stuff a compiler couldn't
% figure out.
my_predicate := true. % my_predicate is valid under any pretense
View butchered.js
function archiveWeeks(tasks) {
return lodash.chain(tasks)
.reverse()
.groupBy({created_at} => new Date(created_at.getFullYear(), created_at.getMonth(), created_at.getDate()))
.map((t, d) => {date: new Date(d), tasks: t})
.groupBy(weekOf) // because I'm lazy
.map((d, w) => {week: w, days: d})
.value();
}
View example.hs
findById :: User.Id -> forall s. Tx Postgres s (Maybe User)
findById userId = do
result <- maybeEx [stmt|
SELECT id, email, created_at, updated_at
FROM users
WHERE id = $userId
|]
return case result of
Just row -> toUser row
@L8D
L8D / wm.js
Last active Aug 29, 2015 — forked from gajus/wm.js
View wm.js
let wm = new WeakMap();
class Foo {
constructor () {
var privateData = {};
wm.set(this, privateData);
privateData.myProperty = 1;
}
View being-fast.md
@L8D
L8D / gist:5498414
Last active Dec 16, 2015
Snippet of a javascript date formatter.
View gist:5498414
return d.getUTCFullYear()
+ '-' + zeroFill(d.getUTCMonth() + 1, 2)
+ '-' + zeroFill(d.getUTCDate(), 2)
+ 'T' + zeroFill(d.getUTCHours(), 2)
+ ':' + zeroFill(d.getUTCMinutes(), 2)
+ ':' + zeroFill(d.getUTCSeconds(), 2)
+ '.' + zeroFill(d.getUTCMilliseconds() * 1000, 6)
+ 'Z';
@L8D
L8D / gist:6148641
Created Aug 4, 2013
Public SSH key
View gist:6148641
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDSB6JUsqH814A5N78yQv/vy2UvHDUQGSIkknGiwRyQjX5h4aodgM6unvcIo1kZUldDCa4kxoUP1hN2Slb9UNWH/gwvSwmHI5T6M8W6b2kEcv4PX5BBn+V2aNI5KULq3OOevIrv5ofYf0shqRmX39mxLd2UU5tVLGYrx9OdYFK+2aRU6PJfMU8g2z6ArEqIvur81TeFnqdCMcihkM/1SnmBn/7c+/TfvjNm6xBBk2MC5Pw6iSTGi/JkIllMCXfV8FFvs4hYl0vfUowbBFdp5VQNrbYIJ8Qnn09hAilyFTRTlidkgAiAjr78pkClsisUA/M9lSjeD6G/7yhfO8o+Xv9J seed@Alex
You can’t perform that action at this time.