Skip to content

Instantly share code, notes, and snippets.

@bchase
bchase / tz.js
Last active October 6, 2018 18:49
// what we get
new Date('2018-10-01')
// Sun Sep 30 2018 20:00:00 GMT-0400 (Eastern Daylight Time)
// what we want
new Date('2018-10-01 GMT-0400')
// Mon Oct 01 2018 00:00:00 GMT-0400 (Eastern Daylight Time)
#!/usr/bin/env ruby
class Pawn
def move_down?(x,y)
can_move_distance?(x,y)
end
def move_up?(x,y)
can_move_distance?(x,y)
#!/usr/local/bin/node
//////////////////
// Combinations //
//////////////////
// build all consecutive combination of elements, given an array
function getConsecutiveCombinations(orig_arr) {
#!/usr/bin/env stack
-- stack runghc --resolver lts-9.14 --install-ghc --package mtl
{-# LANGUAGE CPP #-}
import Control.Monad.Trans.Maybe (MaybeT(MaybeT), runMaybeT)
import Control.Monad.Trans.Except (ExceptT(ExceptT), runExceptT)
import System.Environment (lookupEnv)

Persistent

Persistent does make use TH, but it only requires you to use it as a consumer. That is: you define your schema using its DSL, and then it generates your migrations, data types, instances, etc. for you (which uses TH under the hood).

Schema

To give you an idea of what to expect, here's a psuedo-code version of a schema definition:

#!/usr/bin/env ruby
require 'pathname'
require 'uri'
module HTML
def table(txt)
node('table', txt)
end
#!/usr/bin/env ruby
require 'pathname'
require 'uri'
module HTML
def table(txt)
node('table', txt)
end
#!/usr/bin/env ruby
require 'pathname'
module HTML
def table(txt)
node('table', txt)
end
#!/usr/bin/env ruby
require 'sinatra'
set :port, ENV['PORT'] || 8080
get '*/elm.js' do |_|
send_file 'dist/elm.js'
end
module AoC201704A exposing (..)
a1 : List String -> Int
a1 lines =
let
valid : String -> Bool
valid passphrase =
List.length (S.split " " passphrase) == List.length (L.unique (S.split " " passphrase))
in