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
let shouldMatch f x = | |
try f x |> ignore | |
with :? MatchFailureException as e -> | |
failwithf "Did not expect %A" x | |
[<Test>] | |
let ``something should something`` () = | |
some "complicated" (funct "call") | |
|> shouldMatch (function | This (That _) _ And (These "things") -> ()) |
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
module Test = | |
open System | |
open System.Diagnostics | |
let bench (actionFactory : unit -> (unit -> unit), | |
minIterations : int option) = | |
let minIterations = defaultArg minIterations 1 | |
let properTime (action : unit -> unit) |
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
#!/bin/bash | |
# this script recodes phone videos to a lower bitrace encoding to save space. | |
# phones typically encode at a very high bitrate because they don't have enough | |
# CPU power to do a more compressed encoding in real time. | |
# generally this recoding does not affect perceived video quality. | |
# USAGE: encodevid.sh [path] | |
QUALITY=26.0 | |
INPATH=$1 |
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
import random | |
random.seed() | |
import math | |
def rnd(_from=0, _to=1): return _from + random.random() * (_to - _from) | |
def rectangle_random(W=2, H=2): | |
return (rnd(0, W), rnd(0, H)) |
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
#!/bin/bash | |
which stack > /dev/null | |
if [ $? -ne 0 ]; then | |
if [ ! -f ./.stack/stack ]; then | |
OS=`uname` | |
if [ $OS == "Darwin" ]; then | |
STACK_URL=https://github.com/commercialhaskell/stack/releases/download/v0.1.3.1/stack-0.1.3.1-x86_64-osx.gz | |
elif [ $OS == "Linux" ]; then | |
STACK_URL=https://github.com/commercialhaskell/stack/releases/download/v0.1.3.1/stack-0.1.3.1-x86_64-linux.gz | |
else |
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
#!./stack | |
-- stack --resolver lts-2.14 --install-ghc runghc --package hspec --package QuickCheck | |
module Carrotland where | |
import Data.List (sort, find, partition) | |
import Data.Maybe (fromMaybe) | |
type Point = (Integer, Integer) | |
-- projection of a segment on X and Y axes, respectively |
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
(ns overtone-xmas.bells | |
( :use [overtone.live] | |
[overtone.sc.machinery.defcgen])) | |
;;http://computermusicresource.com/Simple.bell.tutorial.html | |
(def dull-partials | |
[ | |
0.56 |
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
;;; ENVIRONMENTAL IMPACT STATEMENT | |
;;; | |
;;; This program was written on recycled memory. | |
;;; No cons cells were created. | |
;;; | |
(ns interpolate | |
(:use [clojure.walk :only (postwalk)])) | |
(defmacro s |
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
;;Using the Cassowary constraint solver from ClojureScript | |
;;This demo shows using multimethods for readable constraint syntax using +, -, and =. | |
;;Output is a row of circles with random radii spaced so that the space between their boundaries is uniform. | |
(ns c2.main | |
;;refer-clojure :exclude is currently broken in ClojureScript master | |
;;Ticket open: http://dev.clojure.org/jira/browse/CLJS-114 | |
;;Fix applied here: https://github.com/lynaghk/clojurescript/tree/114-refer-clojure-exclude | |
(:refer-clojure :exclude [+ - =]) | |
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
(defn group [xs] | |
"splits its sequence argument into a list of lists of equal, adjacent elements." | |
(partition-by identity xs)) | |
(defn zip [xs ys] | |
"makes a list of vector tuples, each tuple containing elements of both sequences occuring at the same position" | |
(map vector xs ys)) | |
(defn lines [str] | |
"For a given string, split it into a vector using a newline terminator as a delimiter" |
OlderNewer