Skip to content

Instantly share code, notes, and snippets.

@IwanKaramazow
IwanKaramazow / missing lo
Created February 10, 2020 09:28
missing.ns
open BinarySearchTree
module List = Belt.List
let rec weave = (list1, list2, prefix, results) =>
switch (list1, list2) {
| (list[], _) | (_, list[]) =>
let everything = List.concatMany([prefix, list1, list2])->List.toArray
results->Js.Array2.push(everything)->ignore
| (list[hd1, ...tail1], list[hd2, ...tail2]) =>
@IwanKaramazow
IwanKaramazow / test.s
Created January 16, 2020 18:39
echo "let _ = print_endline (string_of_bool ((Some \"asd\") == (Some \"asd\" ) ))" > test.ml && ocamlopt -S -o foobar.exe test.ml
.file ""
.section __TEXT,__literal16,16byte_literals
.align 4
_caml_negf_mask:
.quad 0x8000000000000000
.quad 0
.align 4
_caml_absf_mask:
.quad 0x7fffffffffffffff
@IwanKaramazow
IwanKaramazow / oldskool.re
Last active March 15, 2018 04:27
Uncurried syntax
/* uncurried function definition */
let add = [@bs] (a, b) => a + b;
/* uncurried function application */
let two = [@bs] add(1, 2);
/* uncurried callbacks === inline uncurried function definition */
setTimeout([@bs] () => Js.log("test"), 1000);
Arguments:
/usr/local/bin/node /usr/local/lib/node_modules/esy/node_modules/@esy-ocaml/esy-install/bin/esy-install.js --cache-folder /usr/local/lib/node_modules/esy/bin/../_esyInstallCache-3.x.x install
PATH:
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
Yarn version:
1.2.1013
Node version:
@IwanKaramazow
IwanKaramazow / awkard.re
Created June 18, 2016 19:02
Js_of_ocaml
let module Title = React.CreateComponent {
type props = string;
/* this part is a lot of boilerplate */
type underlyingJsValue = Js.t Js.js_string;
let to_js props => Js.string props;
let from_js js_props => Js.to_string js_props;
/* end of boilerplate */
let render props => H1.make [Text props];
@IwanKaramazow
IwanKaramazow / clojurescript
Last active February 13, 2016 10:00
om/set-query! original query
(defui RootView
static om/IQuery
(query [_]
[:property])
...)
(om/set-query! RootView {:query (om/get-query RootView)})
;; => #object[Error Error: Assert failed: Query violation, [object Object] reuses function etc.
@IwanKaramazow
IwanKaramazow / links.cljs
Last active February 1, 2016 15:54
Thinking with reification links
@IwanKaramazow
IwanKaramazow / om-tutorial.cljs
Created January 6, 2016 22:07
Experimentation with Om Next
(ns om-tutorial.core
(:require-macros [cljs.core.async.macros :refer [go]])
(:require [goog.dom :as gdom]
[cljs.core.async :as async :refer [<! >! put! chan]]
[clojure.string :as string]
[om.next :as om :refer-macros [defui]]
[om.dom :as dom]
[datascript.core :as d]
[cognitect.transit :as t])
(:import [goog Uri]
@IwanKaramazow
IwanKaramazow / om.cljs
Last active January 6, 2016 21:56
Om next Rootquery
;; wrong RootQuery
(defui RootView
static om/IQueryParams
(params [this]
{:year (om/get-query Year)
:yearTitle (om/get-query YearTitle)
:resultQuery (om/get-query ResultList) ;; here I 'stole' the full query from ResultList, doesn't work
:selected 2015})
static om/IQuery