This file contains hidden or 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
def coerceDate(dateFormat: String)(dateAsString: String) = { | |
val fmt = new java.text.SimpleDateFormat(dateFormat) | |
val dt = fmt.parse(dateAsString) | |
new java.sql.Date(dt.getYear, dt.getMonth, dt.getDay) | |
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or 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
#!/bin/env bash | |
function tt() { | |
osascript &>/dev/null <<EOF | |
tell application "iTerm2" | |
tell current window | |
create tab with default profile command "$@" | |
end tell | |
end tell | |
EOF |
This file contains hidden or 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
#!/usr/bin/env bash | |
# From: https://en.wikipedia.org/wiki/Oblique_Strategies | |
strategies=( | |
"(Organic) machinery" | |
"A line has two sides" | |
"A very small object Its center" | |
"Abandon desire" | |
"Abandon normal instructions" |
This file contains hidden or 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
// Uses https://github.com/krasimir/EventBus | |
var app = (function (document, bus) { | |
function appInit(event, appstate) { | |
var response = prompt("Foo?"); | |
if (response == "foo") { | |
bus.dispatch("render", this, {"status": "ok"}); | |
} else { | |
bus.dispatch("render", this, {"status": "errou-mane"}); |
This file contains hidden or 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
from scipy.spatial.distance import euclidean | |
import numpy as np | |
from __future__ import division | |
def periodic_distance(a, b, period=12): | |
""" | |
Euclidean distance w/ periodic boundaries. | |
>>> A = np.array([1, 12, 1]) | |
>>> B = np.array([12, 1, 1]) |
This file contains hidden or 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
import System.Random | |
import Data.List | |
mu :: Fractional a => [a] -> a | |
mu [] = 0 | |
mu ps = sum ps / (fromIntegral . length) ps | |
sigma :: Floating a => [a] -> a | |
sigma [] = 0 | |
sigma ps = sqrt (mu $ map xm ps) |
This file contains hidden or 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
import collections | |
import toolz | |
import decorator | |
## same boilerplate as in common_models | |
class Stage(object): | |
def __init__(self, **constants): |
This file contains hidden or 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
import collections | |
## same boilerplate as in common_models | |
class Stage(object): | |
def __init__(self, **kwargs): | |
self.constants = kwargs |
This file contains hidden or 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
from __future__ import unicode_literals, print_function, generators | |
import doctest | |
# TODO: | |
# - 'do' notation | |
# - Py3 type annotations | |
# - More monadic types | |
class FormattedException(Exception): | |
def __init__(self, **kwargs): |