Skip to content

Instantly share code, notes, and snippets.

Avatar

Philip Nilsson philipnilsson

View GitHub Profile
View keybase.md

Keybase proof

I hereby claim:

  • I am philipnilsson on github.
  • I am philip_nilsson (https://keybase.io/philip_nilsson) on keybase.
  • I have a public key ASDHkjtDR2r-GC38Hf-Nfgu3rvC7nksXqOKS7_8EYji1swo

To claim this, I am signing this object:

View gist:51676fa5a394f66be9f810c6032b0927
(setq-default line-spacing 4)
;; Supress initial scratch message
(setq initial-scratch-message nil)
(require 'package)
(add-to-list
'package-archives
'("melpa" . "http://melpa.milkbox.net/packages/") t)
(package-initialize)
View keybase.md

Keybase proof

I hereby claim:

  • I am philipnilsson on github.
  • I am philip_nilsson (https://keybase.io/philip_nilsson) on keybase.
  • I have a public key ASDIhySUyBJvD-Ahd2EPn5ikDIUtBx35zxE7GnupBor34Ao

To claim this, I am signing this object:

View excustion.hs
-- Run a stateful computation and on completion
-- restore state to it's current value.
excursion st = do
oldState <- get
st
put oldState
View nested-lists-functions.js
// Some functional utilities
const map = f => arr => arr.map(f);
const id = x => x;
const concat = xs => [].concat(...xs);
const fold = (f, init) => xs => xs.reduce(f, init);
const sum = fold((x, y) => x + y, 0);
// Nested-list algebras
function alg(leaf, branch) {
return nested => nested instanceof Array
View gist:fa7dc0dba708ef3f218b
combine :: [Either a b] -> ((a,b) -> c) -> [c]
combine xs f = combine' (Nothing, Nothing) xs
where
combine' (_, Just y) (Left l:xs) =
f (l,y) : combine' (Just l, Just y) xs
combine' (Just x, _) (Right l:xs) =
f (x,l) : combine' (Just x, Just l) xs
combine' (_, y) (Left l : xs) =
combine' (Just l, y) xs
combine' (x, _) (Right l : xs) =
View gist:0dcfc1c403b7164758c3
module Main where
import Engine
pretty elem
= elem $= texture (fromFile "slim.jpg")
scene =
pretty cube $= rotateX 2t $= rotateY 3t
View gist:c3a082fb2dc27f0a39cd
vShader :: SC.Shader GLfloat
vShader = do
pos <- attribute vec3 "position"
a_color <- attribute vec3 "a_color"
color <- varying vec3 "color"
gl_Position =: pos .: 1
color =: pos
fShader :: SC.Shader GLfloat
View gist:7b0974e4a8094c04efb3
data Pair a = Pair a a
data Exp typ where
Vec :: Exp a -> Exp a -> Exp (Pair a)
Const :: Int -> Exp Int
-- with type
type RHS typ = String
View gist:dff38644687dd3ec8eed
import System.Random
import Control.Monad
count = length . filter id
avenge = do
x <- replicateM 8 randomIO
return $ count x <= 4
test n = do
You can’t perform that action at this time.