Skip to content

Instantly share code, notes, and snippets.

module Types.Scratch exposing (HasComments)
import RemoteData as RD exposing (RemoteData(..), WebData)
import Types.Clip.Comment as Comment exposing (Comment)
type alias HasComments m =
-- haskell syntax, btw
data Maybe a
= Nothing
| Just a
noStringHere :: Maybe String
noStringHere = Nothing
aStringHere :: Maybe String
module Email
def self.get_domain(email_address)
email_address&.split('@')&.last
end
end
emails = [ 'brad@these8bits.com' ]
p emails.map(&Email.method(:get_domain))
@bchase
bchase / App.js
Last active October 10, 2018 22:15
// app/assets/javascripts/App.js
class App {
static initJobShow() {
$(document).ready(function(){
let user_id = $(".user-id").data("id")
let job_id = $(".job-id").data("id")
$.get(`/users/${user_id}/jobs/${job_id}.json`, function(data) {
let job = new Job(date, user_id)
// app/assets/javascripts/jobs/show.js
$(document).ready(function(){
const displayJobDetails = function (job) {
$('#foo').append(JobView.renderJobShow(job))
}
})
// // jobs/show.html.erb
// ...
@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)