Skip to content

Instantly share code, notes, and snippets.

@Risto-Stevcev
Risto-Stevcev / index.html
Last active September 4, 2017 23:20 — forked from anonymous/index.html
Web Components Example JS Bin// source http://jsbin.com/rogopipubo
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/webcomponentsjs/1.0.10/custom-elements-es5-adapter.js"></script>
<style id="jsbin-css">
::content .product-img {
width: 12px;
@Risto-Stevcev
Risto-Stevcev / moore.re
Created August 19, 2017 11:53
Moore machine in reason
type moore 'x 'y =
| Moore 'x ('y => moore 'x 'y);
let rec contramap f (Moore x step) => Moore x (fun y => contramap f (step (f y)));
let rec map f (Moore x step) => Moore (f x) (fun y => map f (step y));
let extract (Moore x step) => x;
let rec extend f (Moore x step as self) => Moore (f self) (fun y => extend f (step y));
let step x (Moore _ step) => step x;
module ReducerExample = {
type state 'a = | LoggedIn 'a | LoggedOut | Initial;
@Risto-Stevcev
Risto-Stevcev / .XCompose
Created August 4, 2017 11:59
A custom Compose file for easier key bindings to math symbols
# UTF-8 (Unicode) compose sequence
# David.Monniaux@ens.fr
#
# This is a custom compose file for writing easy unicode math symbols, it's placed in the $HOME dir
<Multi_key> <a> : "∀" U2200 # FOR ALL
<Multi_key> <semicolon> : "∷" U2237 # PROPORTION
<Multi_key> <comma> : "←" U2190 # LEFTWARDS ARROW
<Multi_key> <period> : "→" U2192 # RIGHTWARDS ARROW
<Multi_key> <equal> <comma> : "⇐" U21D0 # LEFTWARDS DOUBLE ARROW
@Risto-Stevcev
Risto-Stevcev / unicode.md
Last active August 4, 2017 12:27
Unicode support and typing math operators on linux

Here are some steps to set up the ability to type unicode math operators in vim:

  1. Enable the compose key:
    setxkbmap -option compose:ralt

  2. Create a custom Compose file (recommended). Place it in $HOME. Here's a very brief example:

# ~/.XCompose
<Multi_key> <a> : "∀"  U2200 # FOR ALL
@Risto-Stevcev
Risto-Stevcev / io-demo.js
Last active July 28, 2017 17:15
A simple description in JS on how haskell style IO works and how it's written in strict languages
var fs = require('fs')
/*
* - The key is that everything is wrapped in a closure, so effects don't do anything until they're run
* - JS is untyped, but you can think of these as having an IO type. `readFile` for example is like `String -> IO String`
* - Some view functions like `readFile`, `writeFile`, etc here as 'recipes', because the actual side effect is
* in a closure, and it's almost as if it describes an intent to run a side effect, but doesn't do so until
* it's actually run.
* - You can chain these recipes (or intentions) together to form a program
* - These functions like `readFile` are pure because calling it any number of times always returns the same thing,
@Risto-Stevcev
Risto-Stevcev / AddVsMul.ml
Created July 16, 2017 15:12
Choosing abstractions based on Additive vs Multiplicative Monoids for Int
open List
module type Monad = sig
type 'a t
val map : ('a -> 'b) -> 'a t -> 'b t
val pure : 'a -> 'a t
val bind : 'a t -> ('a -> 'b t) -> 'b t
end
module type Monoid = sig
type t
@Risto-Stevcev
Risto-Stevcev / STLC.idr
Created June 24, 2017 13:31
Simply typed lambda calculus in Idris
module STLC
%default total
-- Types
infixr 0 :=>
data Ty : Type where
@Risto-Stevcev
Risto-Stevcev / Bug.idr
Last active June 15, 2017 12:58
Some bug? in idris?
data CatQueue a = MkCatQueue (List a) (List a)
data NonEmptyQueue : CatQueue a -> Type where
IsNonEmptyQueue : Either (NonEmpty xs) (NonEmpty ys) -> NonEmptyQueue (MkCatQueue xs ys)
Uninhabited (NonEmptyQueue (MkCatQueue [] [])) where
uninhabited (IsNonEmptyQueue (Left IsNonEmpty)) impossible
uninhabited (IsNonEmptyQueue (Right IsNonEmpty)) impossible
qqqq : (q : CatQueue a) -> {auto prf : NonEmptyQueue q} -> Unit
@Risto-Stevcev
Risto-Stevcev / index.html
Last active May 8, 2017 04:53
Creating a redux style store with RxJS observables
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://rawgit.com/Reactive-Extensions/RxJS/master/dist/rx.lite.js"></script>
</head>
<body></body>
</html>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://unpkg.com/most/dist/most.min.js"></script>
<script src="https://rawgit.com/Reactive-Extensions/RxJS/master/dist/rx.lite.js"></script>
</head>
<body>