Skip to content

Instantly share code, notes, and snippets.

View rizo's full-sized avatar

Rizo rizo

  • Porto (Portugal)
View GitHub Profile
@rneswold
rneswold / lwt_fstream.ml
Last active November 4, 2021 21:20
Functional streams for LWT
open Lwt.Infix
exception Source_terminated
type 'a node = N of ('a * 'a node Lwt.t)
type 'a t = 'a node Lwt.t
let push ref_waker v =
let new_node, new_waker = Lwt.wait () in
@itod
itod / split_keyboards.md
Last active June 18, 2025 03:13
Every "split" mechanical keyboard currently being sold that I know of
#include <stdio.h>
typedef struct {
int tag;
union {
int l;
struct {
char* fst;
float snd;
} r;
@ericbn
ericbn / .vimrc
Last active June 30, 2025 23:48
Vim Powerline-like status line without the need of any plugin
" Statusline (requires Powerline font)
set statusline=
set statusline+=%(%{&buflisted?bufnr('%'):''}\ \ %)
set statusline+=%< " Truncate line here
set statusline+=%f\ " File path, as typed or relative to current directory
set statusline+=%{&modified?'+\ ':''}
set statusline+=%{&readonly?'\ ':''}
set statusline+=%= " Separation point between left and right aligned items
set statusline+=\ %{&filetype!=#''?&filetype:'none'}
set statusline+=%(\ %{(&bomb\|\|&fileencoding!~#'^$\\\|utf-8'?'\ '.&fileencoding.(&bomb?'-bom':''):'')

This document has moved!

It's now here, in The Programmer's Compendium. The content is the same as before, but being part of the compendium means that it's actively maintained.

@gatlin
gatlin / 1-js-lenses.md
Last active June 5, 2025 19:20
Simple implementation of lenses in JavaScript

What is a lens?

Note: you can copy the file 2-lenses.js below over to repl.it and play along from home!

A lens in programming, much like a lens in the real world, allows you to focus in on a small part of a larger whole and then do something with or to

@rneswold
rneswold / lwt_stream.ml
Last active November 4, 2021 21:20
Alternate `Lwt_stream` (structure)
open Lwt.Infix
exception End_of_stream
type 'a node = N of 'a * 'a node Lwt.t
type 'a t = 'a node Lwt.t ref
let push ref_waker v =
let new_node, new_waker = Lwt.wait () in
@aisamanra
aisamanra / pratt.hs
Created March 11, 2016 22:22
a simple pratt parser in Haskell
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
import Data.Map.Strict (Map)
import qualified Data.Map.Strict as M
import MonadLib
type Tables t a = (PrefixMap t a, InfixMap t a)
newtype PrattM t r a = PrattM
{ runPrattM :: ReaderT (Tables t r) (StateT [t] (ExceptionT String Id)) a
@gatlin
gatlin / my_prelude.hs
Last active September 19, 2017 23:36
{- * Foundational functions -}
id :: a -> a
id x = x
const :: a -> b -> a
const x y = x
fix :: (a -> a) -> a
fix f = f (fix f)
@gatlin
gatlin / orca.hs
Last active September 19, 2017 23:37
yeah I'm thinking about Orc again
{-
This came from looking at the source for the orc package on hackage.
I wanted to know why it works, and to see if I can come up with an
alternative implementation which does cool things, and possibly provide
a mechanism for orchestrating non-linear tube computations.
-}
-- | Pilfered from the orc package on Hackage.
-- The original is specialized to one MonadIO instance.
-- Also this looks suspiciously like a continuation monad.