Skip to content

Instantly share code, notes, and snippets.

View dyokomizo's full-sized avatar

Daniel Yokomizo dyokomizo

View GitHub Profile
//
// On MacOSX compile with:
// g++ -framework OpenGL -framework GLUT -o example example.cpp
//
#include <stdlib.h>
#include <GLUT/glut.h>
GLuint program;
@sjoerdvisscher
sjoerdvisscher / zipper.hs
Created January 11, 2012 23:10
A zipper for traversables.
import Data.Traversable
import Control.Monad.Free
import Control.Comonad
import Control.Comonad.Trans.Store
type Zipper t a = Free (Store a) (t a)
zipper :: Traversable t => t a -> Zipper t a
zipper = traverse (wrap . store return)
@copumpkin
copumpkin / Split.agda
Last active September 30, 2015 02:48
Split
module Split where
open import Data.Bool
open import Data.Nat
open import Data.Nat.Properties
open import Data.List hiding ([_])
open import Data.Product
open import Relation.Binary
open import Relation.Binary.PropositionalEquality
@manuel
manuel / define-constructor.scm
Created February 22, 2012 15:40
Adventures in Hygienic Fexprs
;; As part of the implementation of Virtua's [1] object system I need
;; a facility called DEFINE-CONSTRUCTOR that defines a convenient
;; function for creating an instance of a class and setting its slots.
(define-constructor make-person Person (firstname lastname))
;; should be operationally equivalent to
(define make-person
(lambda (firstname lastname)
@sjoerdvisscher
sjoerdvisscher / traversable-dissection.hs
Created March 2, 2012 09:49
Dissecting Traversables
import Control.Monad.Free
import Data.Functor.Compose
import Data.Traversable
type Diss p c j = c -> Free (Compose ((,) j) ((->) c)) (p c)
right :: Traversable p => Either (p j) (Diss p c j, c) -> Either (j, Diss p c j) (p c)
right e = case either (traverse (\j -> Free (Compose (j, Pure)))) (uncurry ($)) e of
Free (Compose jd) -> Left jd
Pure pc -> Right pc
@hrldcpr
hrldcpr / tree.md
Last active June 19, 2025 08:17
one-line tree in python

One-line Tree in Python

Using Python's built-in defaultdict we can easily define a tree data structure:

def tree(): return defaultdict(tree)

That's it!

@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@copumpkin
copumpkin / Types.agda
Last active October 17, 2021 11:24
Types form a commutative semiring!
module Types where
open import Level
open import Function
open import Algebra
open import Data.Empty
open import Data.Unit
open import Data.Sum as Sum
open import Data.Product as Prod
open import Relation.Binary
@mbbx6spp
mbbx6spp / GITHUB-COMPARE-LINKS.md
Created June 21, 2012 03:37
This Gist is worth a million beers. So buy me one (or send me a really cool t-shirt, make sure it is REALLY cool though)! :)