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
blacktaxi / Carrotland.hs
Created Sep 29, 2015
Solution for a classic algo problem
View Carrotland.hs
#!./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
@blacktaxi
blacktaxi / stack
Created Sep 29, 2015
stack bootstrapper
View stack
#!/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
@blacktaxi
blacktaxi / recodevid.sh
Created Aug 9, 2015
Save space on HD phone videos
View recodevid.sh
#!/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
@blacktaxi
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
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
[<Test>]
let ``something should something`` () =
some "complicated" (funct "call")
|> shouldMatch (function | This (That _) _ And (These "things") -> ())
@blacktaxi
blacktaxi / ninject-dynamic-get.cs
Last active Dec 24, 2015
Ninject ConstructorArguments as named parameters to a dynamic invoke
View ninject-dynamic-get.cs
namespace Ninject
{
public static class NinjectExtensions
{
private class DynKernel : DynamicObject
{
private readonly IKernel kernel;
public DynKernel(IKernel inner)
{
@blacktaxi
blacktaxi / signextlib.bat
Created Sep 17, 2013
Shell script to sign a .NET assembly.
View signextlib.bat
@echo off
"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bin\sn.exe" -q -vf "%1" > NUL
if ERRORLEVEL 1 goto NOT_SIGNED
:SIGNED
echo Already signed: %~nx1
goto END
:NOT_SIGNED
@blacktaxi
blacktaxi / markdown_block.rb
Created Aug 30, 2013
Inline markdown blocks in Jekyll layouts/pages.
View markdown_block.rb
module Jekyll
class MarkdownBlock < Liquid::Block
def initialize(tag_name, text, tokens)
super
end
require "kramdown"
def render(context)
content = super
"#{Kramdown::Document.new(content).to_html}"
end
View gist:6281977
open System.IO
open System.Net
let wc = new WebClient()
let trainingSetFile = Path.Combine( __SOURCE_DIRECTORY__, "trainingSet.csv")
File.WriteAllText(trainingSetFile,
contents = wc.DownloadString("http://brandewinder.blob.core.windows.net/public/trainingsample.csv")
)
@blacktaxi
blacktaxi / __hooks__.py
Created Jul 28, 2013
Super-hack to enable hamlish-jinja templates in Wok.
View __hooks__.py
from hamlish_jinja import HamlishTagExtension
from jinja2.environment import load_extensions
def enable_haml(page):
env = page.__class__.tmpl_env
env.extensions = load_extensions(env, [HamlishTagExtension])
hooks = {
'page.meta.pre': [enable_haml]
}
You can’t perform that action at this time.