Skip to content

Instantly share code, notes, and snippets.

View rizo's full-sized avatar

Rizo rizo

  • Porto (Portugal)
View GitHub Profile
Exception in thread "Thread-3" SocketException The transport's socket appears to have lost its connection to the nREPL server
clojure.lang.ExceptionInfo: Subprocess failed {:exit-code 137}
at clojure.core$ex_info.invoke(core.clj:4403)
at leiningen.core.eval$fn__6725.invoke(eval.clj:236)
at clojure.lang.MultiFn.invoke(MultiFn.java:231)
at leiningen.core.eval$eval_in_project.invoke(eval.clj:337)
at leiningen.repl$server$fn__10717.invoke(repl.clj:241)
at clojure.lang.AFn.applyToHelper(AFn.java:152)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invoke(core.clj:624)
type v2 = { x : float;
y : float }
let lerp a b v =
a *. (1.0 -. v) +. b *. v
let smooth v =
v *. v *. (3.0 -. 2.0 *. v)
@rizo
rizo / uniques.ml
Last active August 29, 2015 14:19 — forked from cqfd/uniques.ml
let rec elem x xs =
match xs with
| [] -> false
| y :: ys -> x = y || elem x ys
let rec uniques l =
let rec helper l acc =
match l with
| [] -> acc
| x :: xs ->
$ opam install --verbose ketrew
The following actions will be performed:
- install ketrew.master
=== + 1 ===
=-=- Synchronizing package archives -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
[ketrew] Fetching https://github.com/hammerlab/ketrew
HEAD is now at b782227 Remove obsolete configuration value
=-=- Installing packages =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
type point = { x : int; y : int };;
type 'a cell = { coord : point; level : int; cargo : 'a } ;;
List.Assoc.find;;
let assoc = [(2, "a"); (3, "b"); (5, "d")];;
List.Assoc.find assoc 3;;
\ntype point = { x : int; y : int }\nlet point ~x ~y = { x ; y }\n;;
point ~x:2 ~y: 12;;
let point_of_pair (x, y) = point ~x ~y;;
let points = List.map [(1,2); (3, 1); (5, 1); (10; 23)] ~f:point_of_pair;;
let points = List.map [(1,2); (3, 1); (5, 1); (10, 23)] ~f:point_of_pair;;
let add_missing_hours
: Date.t -> (Time.t * 'a) list -> (Time.t * 'a) list
= fun date hourly_counts ->
let gen_day_hours ~start =
List.map (List.range 0 24) (fun hr -> Time.add start (Time.Span.create ~hr ())) in
let day_hours = gen_day_hours
~start:(Time.of_date_ofday date Core.Ofday.start_of_day Core.Zone.utc) in
List.fold day_hours ~init:hourly_counts
~f:(fun hourly_counts' hour ->
if List.Assoc.mem hourly_counts' hour then hourly_counts'
@rizo
rizo / coroutine.sml
Created November 17, 2015 23:34 — forked from jozefg/coroutine.sml
signature COROUTINE =
sig
type ('a, 'b, 'r) t
val await : ('a, 'b, 'a) t
val yield : 'b -> ('a, 'b, unit) t
(* Monadic interface and stuffs *)
val map : ('c -> 'd) -> ('a, 'b, 'c) t -> ('a, 'b, 'd) t
val return : 'c -> ('a, 'b, 'c) t
module Person = struct
type t = {
name : string;
age : int;
}
type 'a with_meta = t * 'a
end
open Elements
type ('a, 'state) step = 'state -> 'a -> [ `Continue of 'state | `Stop of 'state ]
type ('a, 'b, 'state) transducer =
('b, 'state) step -> ('a, 'state) step
let map f =
fun step -> fun r x ->
@rizo
rizo / seq.js
Last active January 14, 2016 20:42
// List Processor
function map(f, seq) {
return function(step) {
seq (function(x) {
return step (f(x));
});
};
}