Skip to content

Instantly share code, notes, and snippets.

View lenary's full-sized avatar

Sam Elliott lenary

View GitHub Profile
@lenary
lenary / dlfind.c
Last active October 24, 2017 06:20
Simple Utility to find the path to a dynamic library on your system (by name)
#include <dlfcn.h>
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#ifdef __APPLE__
#include <mach-o/dyld.h>
#else // Linux
#include <link.h>
#endif
@lenary
lenary / test.hs
Last active October 10, 2017 20:40 — forked from elliotdavies/test.hs
Haskell pattern question
-- In `f` we want to keep piping (part of) the result of one function into
-- another, and stop as soon as something fails
f :: [A] -> Either String (B, [A])
f xs =
case f1 xs of
Left s -> Left s
Right (res1, xs') ->
case f2 xs' of
Left s -> Left s
Right (res2, xs'') ->
%% Source Code Notes
\ProvidesPackage{listing-label}
% We use tikz for drawing the circles around the letters. Dumb, probably.
\RequirePackage{tikz}
% Counter, numbered by section
\newcounter{lstlistinglabel}[section]
% Length for left out-dent
\newlength{\lstlabelleftoutdent}
#include <stdio.h>
// The file with the unchecked interface
#include <stdlib.h>
// The Redeclaration with the correct type
void *calloc(size_t nmemb, size_t size) : byte_count(nmemb * size);
#pragma BOUNDS_CHECKED ON
{-# OPTIONS --copatterns #-}
open import Agda.Builtin.Nat
open import Agda.Builtin.Bool
open import Agda.Builtin.Equality
trans : {A : Set} {a b c : A} -> a ≡ b -> b ≡ c -> a ≡ c
trans refl refl = refl
@lenary
lenary / filter.agda
Last active December 11, 2016 07:40
{-# OPTIONS --copatterns #-}
open import Agda.Builtin.Nat
data Vec (A : Set) : Nat -> Set where
[] : Vec A zero
_::_ : {n : Nat} → A → Vec A n → Vec A (suc n)
record Stream (A : Set) : Set where
coinductive
$ racket -iq -e "(require rosette)"
Welcome to Racket v6.4.
> (define (foo) identity)
> foo
#<procedure:foo>
> identity
#<procedure:identity>
> ((foo) 3)
free-identifier=?: contract violation
expected: identifier?
$ erl
Erlang R15B03 (erts-5.9.3.1) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]
Eshell V5.9.3.1 (abort with ^G)
1> <<99,111,110,118,101,114,115,97,116,105,111,110>>.
<<"conversation">>
2> <<100,107,114,100,54,58,104,107,110,120,110,114,115,49>>.
<<"dkrd6:hknxnrs1">>
bind-key -temacs-copy c copy-selection
bind-key -temacs-copy x copy-pipe "reattach-to-user-namespace /usr/bin/pbcopy"
bind-key -temacs-copy z copy-pipe "mate"
@lenary
lenary / 00demo.md
Last active December 18, 2015 17:49 — forked from seancribbs/00demo.md