Skip to content

Instantly share code, notes, and snippets.

View dyokomizo's full-sized avatar

Daniel Yokomizo dyokomizo

View GitHub Profile
@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
@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)
@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
@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)
//
// On MacOSX compile with:
// g++ -framework OpenGL -framework GLUT -o example example.cpp
//
#include <stdlib.h>
#include <GLUT/glut.h>
GLuint program;
@dpiponi
dpiponi / example.cu
Created December 19, 2011 22:42
Minimal CUDA example
#include <stdio.h>
#define N 1000
__global__
void add(int *a, int *b) {
int i = blockIdx.x;
if (i<N) {
b[i] = 2*a[i];
}
@mbbx6spp
mbbx6spp / README.md
Created December 6, 2011 01:11
Idea for getting GitHub URLs for various needs

GitHub (Bash) Shell URLs

Local Shell setup

This is an environment file to source upon shell startup (via .bashrc/.bash_profile or your shell's corresponding file). If your shell isn't Bash you will likely need to port the functions to your shell's syntax.

Setup your local clone of a GitHub repo

When inside your local Git clone of a Github repo you need to do the following (only once per repo):

@mbbx6spp
mbbx6spp / README.md
Created December 4, 2011 04:24
Best UNIX shell-based tools I can't live without with example usages

Best UNIX Shell tools

These are a list of usages of shell commands I can't live without on UNIX-based systems.

Install

Mac OS X

Using Homebrew (yes, I am opinionated) you can install the following tools with the following packages:

@sjoerdvisscher
sjoerdvisscher / 10553.txt
Created November 19, 2011 20:55
10553, church encoded as ((4*((3*(((5^3)*7)+4))+1))+1)
λs.λz.(λs.λz.s(s(s(s z))))(λz.(λs.λz.s(s(s z)))(λz.(λs.λz.s(s(s z)))(λs.λz.s(s(s(s(s z)))))(λz.s(s(s(s(s(s(s z)))))))(s(s(s(s z)))))(s z))(s z)
@soveran
soveran / elements.md
Created November 18, 2011 17:38
Excerpts from The Elements of Programming Style. The source of this compilation is unknown.

The Elements of Programming Style

The following rules of programming style are excerpted from the book "The Elements of Programming Style" by Kernighan and Plauger, published by McGraw Hill. Here is quote from the book: "To paraphrase an observation in The Elements of Style by Strunk and White, the rules of programming style, like those of English, are sometimes broken, even by the best writers. When a rule is broken, however, you will usually find in the program some compensating merit, attained at the cost of the violation. Unless you are certain of doing as well, you will probably do best to follow the rules."