This file contains 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
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 |
This file contains 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 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(); | |
} |
This file contains 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
% 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 |
This file contains 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
{-# 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) |
This file contains 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 Signal(sub) { | |
this.sub = sub; | |
} | |
Signal.prototype = { | |
/** | |
* Applies the given function over each event. | |
*/ | |
map: function(fn) { | |
var sub = this.sub; |
This file contains 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
// 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 |
This file contains 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
// 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 |
This file contains 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 compose(f) { | |
return function(g) { | |
return function(x) { | |
return f(g(x)); | |
}; | |
}; | |
} | |
// allTheNumbersFrom(Zero) -> 0, 1, 2, 3... | |
function allTheNumbersFrom(number) { |
This file contains 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 Game = React.createClass({ | |
render: function() { | |
var x = this.props.x, | |
y = this.props.y; | |
return ( | |
<svg width={Math.max(x + 10, 200)} height={height: Math.max(y + 10, 200)}> | |
<circle cx={50} cy={50} r={2} fill="#000" /> | |
<circle cx={x} cy={y} r={2} fill="#000" /> | |
<line x1={50} y1={50} x2={x} y2={y} stroke="#000" /> |
This file contains 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 parser = require('body-parser') | |
, config = require('./config') | |
, express = require('express') | |
, morgan = require('morgan') | |
, _ = require('lodash') | |
, path = require('path') | |
; | |
var app = module.exports = express(); |