Skip to content

Instantly share code, notes, and snippets.

View devshorts's full-sized avatar

Anton Kropp devshorts

View GitHub Profile
package tests
import com.twitter.finagle.builder.ClientBuilder
import com.twitter.finagle.http.Http
import com.twitter.finatra.httpclient.RequestBuilder
import com.twitter.util.{Await, Future}
import org.junit.runner.RunWith
import org.scalatest.junit.JUnitRunner
import org.scalatest.{BeforeAndAfterAll, FlatSpec, Matchers}
@RunWith(classOf[JUnitRunner])
class ClientObjectTests extends FlatSpec with Matchers with BeforeAndAfterAll {
"A client" should "be closeable" in {
val client =
ClientBuilder()
.dest("localhost:1")
.codec(Http())
.hostConnectionLimit(1)
.build()
// finagle 6.1.33
class ClientObjectTests extends FlatSpec with Matchers with BeforeAndAfterAll {
"A client" should "be closeable" in {
val client =
ClientBuilder()
.dest("localhost:1")
.codec(Http())
.hostConnectionLimit(1)
.build()
" nerdtree mapping
map <F3> :NERDTreeToggle<CR>
" enabled mouse
set mouse=a
" enable osx clipboard
set clipboard=unnamed
@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 {
@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 / 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: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: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: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