Skip to content

Instantly share code, notes, and snippets.

Sergey Yavnyi blacktaxi

Block or report user

Report or block blacktaxi

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
blacktaxi / ShouldMatch.fs
Created Jul 5, 2015
Poor man's complex pattern matching in F# tests
View ShouldMatch.fs
let shouldMatch f x =
try f x |> ignore
with :? MatchFailureException as e ->
failwithf "Did not expect %A" x
let ``something should something`` () =
some "complicated" (funct "call")
|> shouldMatch (function | This (That _) _ And (These "things") -> ())
blacktaxi / StructVsDU.fs
Last active Aug 29, 2015
F#: DU vs Struct performance
View StructVsDU.fs
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)
blacktaxi /
Created Aug 9, 2015
Save space on HD phone videos
# 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: [path]
blacktaxi / gist:1575749
Created Jan 7, 2012
Generating random points inside a circle
View gist:1575749
import random
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))
blacktaxi / stack
Created Sep 29, 2015
stack bootstrapper
View stack
which stack > /dev/null
if [ $? -ne 0 ]; then
if [ ! -f ./.stack/stack ]; then
if [ $OS == "Darwin" ]; then
elif [ $OS == "Linux" ]; then
blacktaxi / Carrotland.hs
Created Sep 29, 2015
Solution for a classic algo problem
View Carrotland.hs
-- 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
blacktaxi / bells.clj
Created Jan 25, 2012 — forked from jennifersmith/bells.clj
Cheesy Holiday Music and bell synthesis example
View bells.clj
(ns overtone-xmas.bells
( :use []
(def dull-partials
View interpolate.clj
;;; This program was written on recycled memory.
;;; No cons cells were created.
(ns interpolate
(:use [clojure.walk :only (postwalk)]))
(defmacro s
blacktaxi / main.clj
Created Jan 25, 2012 — forked from lynaghk/main.clj
Cassowary constraint solver in ClojureScript
View main.clj
;;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:
;;Fix applied here:
(:refer-clojure :exclude [+ - =])
blacktaxi / haskjure.clj
Created Jan 26, 2012 — forked from djhworld/haskjure.clj
useful haskell functions that I can't seem to find in clojure
View haskjure.clj
(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"
You can’t perform that action at this time.