Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View devshorts's full-sized avatar

Anton Kropp devshorts

View GitHub Profile
@devshorts
devshorts / gist:9241323
Last active August 29, 2015 13:56
Investigating why NUnit Assert.AreEqual doesn't work for identitical tuples with arrays
> z;;
val it : int [] * int = ([|1|], 1)
> p;;
val it : int [] * int = ([|1|], 1)
> z.Equals(p);;
@devshorts
devshorts / gist:ab14c8cd5f72555819aa
Created March 1, 2015 21:34
Sample zsh completion for git branches you aren't on
#compdef test
local arguments
_branch(){
val=()
git branch | grep -v "\*" | while read -r branch ; do
val=($val $branch)
done
#!/usr/bin/env bash
ENVIRONMENT=develop
MACHINE=$1
shift
function print_help(){
@devshorts
devshorts / gist:6359736
Last active December 21, 2015 20:09
Crappy discriminated union filtering
let result = test parserStream video
let moov = List.find(function | MOOV(x) -> true | _ -> false) result
let sttsElements =
match moov with
| MOOV(l) ->
List.filter (function | TRAK(_) -> true | _ -> false) l
|> List.map (function | TRAK(l) -> l)
|> List.collect id
@devshorts
devshorts / gist:6399857
Created August 31, 2013 18:31
Find a subset of a sequence or an array in F# given a source collection and a target collection
module x
let list = [-1;0;1;2;3;4;5;6;7;8;9] |> List.toArray
let target = [1;2;3] |> List.toArray
let nope = [4;1;2] |> List.toArray
/// <summary>
/// Sequenes are basically IEnumerable, so you can't do structural equality on them
/// this is why they are converted to an F# list before doing comparison, otherwise
/// their references are compared
@devshorts
devshorts / gist:7423807
Last active December 28, 2015 01:49
Create stream from iterable in java 8
public class StreamUtil<T>{
public static <T> Stream<T> ofIterable(Iterable<T> iter){
Iterator<T> iterator = iter.iterator();
Stream.Builder<T> builder = Stream.builder();
while(iterator.hasNext()){
builder.add(iterator.next());
}
@devshorts
devshorts / gist:7686263
Last active December 29, 2015 14:49
shopping cart question
open System
type Percent = double
type Money = double
type Nth = int
type ProductType =
| Apple
| Orange
| Poo
@devshorts
devshorts / gist:7794811
Last active December 30, 2015 07:19
shopping 2
module Foo where
import Control.Monad
import Common.Utils
import Data.List
import Data.Maybe
newtype Price = Price { getPrice :: Float } deriving (Show, Eq)
data Buyable = Meat | Fruit deriving (Show, Eq)
@devshorts
devshorts / gc.java
Last active February 20, 2016 20:54
A toy generational garbage collector
public enum Mode {
Gen0,
Gen1
}
//=============================
@Data
@EqualsAndHashCode(of = "id")
public class Node {
" nerdtree mapping
map <F3> :NERDTreeToggle<CR>
" enabled mouse
set mouse=a
" enable osx clipboard
set clipboard=unnamed