Skip to content

Instantly share code, notes, and snippets.

View saschatimme's full-sized avatar
💭

Sascha Timme saschatimme

💭
View GitHub Profile
@saschatimme
saschatimme / examples.elm
Created May 29, 2016 10:51
Functional Programming for JavaScript People examples in Elm
{- js
const add1 = (a) => a + 1
const times2 = (a) => a * 2
const compose = (a, b) => (c) => a(b(c))
const add1OfTimes2 = compose(add1, times2)
add1OfTimes2(5) // => 11
-}
add1 = (+) 1
times2 = (*) 2
add1OfTimes2 = add1 << times2
module Phoenix.Presence exposing (Presence, create, onChange, onJoins, onLeaves)
import Dict exposing (Dict)
import Json.Decode as JD exposing (Decoder, Value)
type alias Presence msg =
PhoenixPresence msg
@saschatimme
saschatimme / Interop.re
Created April 10, 2017 14:48
Simple trick to avoid decoding / encoding if one use Bucklesript on client and server
type t = {
test: string,
value: int
};
external consume_client: string => t = "JSON.parse" [@@bs.val];
external prepare_server: t => string = "JSON.stringify" [@@bs.val];
function exponents_helper(curr_sum::Int, target_sum::Int, remaining_elements::Int)::Vector{Vector{Int}}
if remaining_elements == 0
return [[]]
end
if curr_sum == target_sum
return [zeros(Int, remaining_elements)]
end
if remaining_elements == 1
return map(x-> [x], 0:(target_sum - curr_sum))
module Experiment1 = {
type t =
| Disabled
| Control
| VarA
| VarB;
let equal a b =>
switch (a, b) {
| (Disabled, Disabled) => true
| (Control, Control) => true
```
gobi_install ctypes-ios
Switch to 4.04.0+ios+arm64
The following actions will be performed:
∗ install libffi-sys-ios 3.2.1 [required by ctypes-ios]
∗ install ctypes-ios 0.11.2
===== ∗ 2 =====
=-=- Gathering sources =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= 🐫
[ctypes-ios.0.11.2] https://github.com/ocamllabs/ocaml-ctypes/archive/0.11.2.tar.gz downloaded
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@saschatimme
saschatimme / test.re
Created August 17, 2017 09:02
You can extract `MyFunctorReturnType` in a separate module to avoid the repetition
module type MyFunctorReturnType = {let myFunc: unit => string;};
module MyFunctor (Impl: {type myType;}) => {
let myFunc () => "hello";
};
module MyExample =
MyFunctor {
type myType = string;
};
@saschatimme
saschatimme / app.re
Created September 25, 2017 15:16
Partent calls child ref
open ReactNative;
open Style;
type state = {
expression: option string,
keyboardRef: option ReasonReact.reactRef
};
let updateExpression (changeEvent: Keyboard.changeEvent) self =>
function ∇tSTE_threaded(X::Array{Float64,2},
no_objects::Int64,
no_dims::Int64,
no_triplets::Int64,
triplets::Array{Int64,2},
λ::Float64,
α::Float64)
use_log = true
P = 0.0::Float64