Skip to content

Instantly share code, notes, and snippets.

@mjambon
mjambon / Binary.ml
Created November 2, 2021 09:47
Basic arithmetic operations implemented from scratch on unary and binary representations of natural numbers
(* Arithmetic with Binary numbers (unsigned, arbitrary precision!) *)
type digit = Zero | One
type t = digit list
let rec eq a b =
match a, b with
| [], [] -> true
| da :: a, db :: b when da = db -> eq a b
| _ -> false
@VincentCordobes
VincentCordobes / reader.ml
Created April 6, 2019 19:19
Simple Reader monad in OCaml
module Reader = struct
type ('e, 'a) t = Reader of ('e -> 'a)
let run = function
| Reader r -> r
let map f m = Reader (fun env -> f (run m env))
let bind f m = Reader (fun env -> run (f (run m env)) env)
@tel
tel / indents.md
Created November 20, 2016 19:47
Indentation sensitive parser combinators

Indentation sensitive parser combinators

An indentation sensitive parser combinator language is one that helps you express ideas like "this parse only succeeds if it's within the current indentation block". The concept is somewhat small and elegant and is implemented in a few libraries. In this writeup, I will use examples from indents.

Background and goal

The direct goal will be to write the sameOrIndented parser combinator with a type

@cbednarski
cbednarski / factorio.md
Last active April 3, 2024 01:14
Host a factorio server
@ivg
ivg / pv.ml
Last active August 21, 2022 01:48
open Lwt
let block_size = 256 * 4096
let ifd = Lwt_unix.stdin
let ofd = Lwt_unix.stdout
let print spd =
try_lwt
Lwt_io.eprintf "%s\r" (Speed.to_string spd)
with Speed.Undefined -> return_unit
@francoishill
francoishill / visitor_pattern_in_go.go
Last active April 12, 2020 20:45
Visitor Pattern in Golang
package main
//Thanks to http://ecs.victoria.ac.nz/foswiki/pub/Main/TechnicalReportSeries/ECSTR11-01.pdf
import (
"fmt"
)
//We will have multiple car parts
type CarPart interface {
Accept(CarPartVisitor)
@joernchen
joernchen / bounty.txt
Created February 22, 2014 16:17
Bounty writeup
GitHub RCE by Environment variable injection Bug Bounty writeup
Disclaimer: I'll keep this really short but I hope you'll get the key points.
GitHub blogged a while ago about some internal tool called gerve:
https://github.com/blog/530-how-we-made-github-fast
Upon git+sshing to github.com gerve basically looks up your permission
on the repo you want to interact with. Then it bounces you further in
another forced SSH session to the back end where the repo actually is.
@nirenjan
nirenjan / bishop.c
Created January 4, 2013 06:34
Simulate a drunken bishop walk to produce OpenSSL random art.
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#define XLIM 17
#define YLIM 9
#define ARSZ (XLIM * YLIM)
#define DEBUG 0
@MohamedAlaa
MohamedAlaa / tmux-cheatsheet.markdown
Last active May 23, 2024 18:01
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname