Skip to content

Instantly share code, notes, and snippets.

@Risto-Stevcev
Risto-Stevcev / if.prolog
Last active May 25, 2022 01:35
Convenient monotonic if
:- use_module(library(reif)).
% A convenient version that can "understand" the non-monotonic predicates
iff_(Cond, Success, Failure) :-
functor(Cond, _, Arity),
if_(
Arity = 3,
if_(Cond, Success, Failure),
if_([T]>> (call(Cond) -> T = true; T = false), Success, Failure)
).
@Risto-Stevcev
Risto-Stevcev / relation-operation-function.ipynb
Last active March 23, 2020 21:19
What the difference is between relations, operations, and functions
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Risto-Stevcev
Risto-Stevcev / README.md
Created March 13, 2020 09:08
Migrating mdx from ocaml dune < 2.4.0 to dune >= 2.4.0

This is how the require the lambda_streams package and test the output. Try changing the toplevel output to unit Sync.input:

# #require "lambda_streams";;
# open Lambda_streams;;
# let foo = Sync.pure 123;;
val foo : int Sync.input = <fun>
@Risto-Stevcev
Risto-Stevcev / Frontend.ml
Last active October 14, 2019 18:55
Tree shaking only for bs-declaredom
let _ = Js.log "hello world!"
let x =
let open RistostevcevBsDeclaredom.Html in
div [|text "foobar"|]
let _ =
if Js.Option.isSome HotModuleReload.module_hot then
let _ = HotModuleReload.on_accept @@ fun () -> Js.log "accept: reloading..."
and _ = HotModuleReload.on_dispose @@ fun () -> Js.log "dispose: reloading..."
@Risto-Stevcev
Risto-Stevcev / Frontend.ml
Last active October 14, 2019 18:54
Attempt at tree shaking and code splitting combo for bs-declaredom
let _ = Js.log "hello world!"
let x =
let open RistostevcevBsDeclaredom.Html in
div [|text "foobar"|]
let _ =
if Js.Option.isSome HotModuleReload.module_hot then
let _ = HotModuleReload.on_accept @@ fun () -> Js.log "accept: reloading..."
and _ = HotModuleReload.on_dispose @@ fun () -> Js.log "dispose: reloading..."
@Risto-Stevcev
Risto-Stevcev / config
Created August 17, 2019 21:47
i3 config
# This file has been auto-generated by i3-config-wizard(1).
# It will not be overwritten, so edit it as you like.
#
# Should you change your keyboard layout some time, delete
# this file and re-run i3-config-wizard(1).
#
# i3 config file (v4)
#
# Please see https://i3wm.org/docs/userguide.html for a complete reference!
@Risto-Stevcev
Risto-Stevcev / disassembler.erl
Created July 15, 2019 23:57
Disassemble BEAM
-module(disassembler).
-export([disassemble/0]).
disassemble() ->
compile:file('hello.erl', ['S']).
@Risto-Stevcev
Risto-Stevcev / hello.ll
Last active July 15, 2019 23:16
LLVM hello world
; To emit LLVM from C code (for discovery):
; clang -emit-llvm -S hello.c -o hello.ll
; Declare the printf function
declare i32 @printf(i8*, ...)
@.str = private unnamed_addr constant [14 x i8] c"hello world!\0A\00"
define i32 @main() noinline optnone {
call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i32 0, i32 0))
@Risto-Stevcev
Risto-Stevcev / categories.hs
Created March 13, 2019 21:02
Is everything just a monoid in the category of something?
(.) :: (b -> c) -> (a -> b) -> (a -> c) -- functions
(.) :: cat b c -> cat a b -> cat a c -- categories
(++) :: String -> String -> String -- strings
(<>) :: a -> a -> a -- monoids
(<>) :: cat a a -> cat a a -> a a -- categories
(++) :: [a] -> [a] -> [a] -- lists
(<|>) :: f a -> f a -> f a -- alternatives
(<|>) :: cat a a -> cat a a -> a a -- categories
@Risto-Stevcev
Risto-Stevcev / gitvim.sh
Created December 28, 2018 13:46
This script opens changed files from git into neovim
#!/bin/bash
# This script opens changed files from git into neovim
FOR_STATUS=
FOR_LOG=
COMMIT="HEAD"
open_in_vim () {
if [[ ! -z $FOR_LOG ]]; then
git show --pretty="" --name-only $COMMIT | xargs nvim -p