Skip to content

Instantly share code, notes, and snippets.

View quephird's full-sized avatar

danielle quephird

View GitHub Profile
@quephird
quephird / Pi.hs
Created January 21, 2016 00:11
Just an exercise to compute pi based on random number generation
module Pi where
import Data.List.Split (chunksOf)
import System.Random (newStdGen, randoms)
randomTuples :: Int -> IO [(Float, Float)]
randomTuples n = do
seed1 <- newStdGen
seed2 <- newStdGen
let xs = randoms seed1 :: [Float]
@quephird
quephird / fun-with-protocols-and-records.clj
Last active February 20, 2016 17:42
Inspired by some code I read this past week.
;; After seeing some code whereby a suite of function implementations for CRUD operations
;; for a set of object types were exactly the same except for the entity in question,
;; I wondered if there was a way to somehow share implementations. It's not quite OO
;; inheritance but this seems to do the job; I have no idea if this is considered
;; idiomatic Clojure code.
(ns fun-with-protocols-and-records)
;; Based on http://david-mcneil.com/post/1475458103/implementation-inheritance-in-clojure
;;
@quephird
quephird / flamey_shader.frag
Created March 12, 2016 19:44
Just an experiment based on some of the stuff in chapter 7 of The Book of Shaders: http://thebookofshaders.com/07/
uniform vec2 u_resolution;
uniform float u_time;
void main(){
// Normalize the inbound pixel coordinates.
vec2 st = gl_FragCoord.xy/u_resolution.xy;
// Compute the position of the pixel with the origin as the center of the window.
vec2 pos = vec2(0.5)-st;
@quephird
quephird / gears.frag
Created March 15, 2016 05:23
Fragment shader for displaying four interlocking, rotating gears with different colors. Code still needs improvement.
uniform vec2 u_resolution;
uniform float u_time;
#define PI 3.1415926
#define GEAR_COUNT 4
#define GEAR_TEETH 10
#define GEAR_INNER_RADIUS 0.2
#define GEAR_OUTER_RADIUS 0.3
#define GEAR_TOOTH_LENGTH 0.1

Now that Homebrew (as of this writing) downloads version 4.03 of OCaml, that ultimately breaks installation of Emily using this tap. Eventually, you'll encounter an error involving sedlex, namely that the version needed for Emily is incompatible with OCaml 4.03.0, and only works with a 4.02.x version. So... you need to manually download, compile, and install a bunch of things.

Install OCaml

The first thing you need to do is get a hold of OCaml 4.02.3 here because you can't get earlier versions of things via Homebrew. Once downloaded, move into that directory and run the following:

./configure
@quephird
quephird / Keyboard shortcuts.txt
Last active February 15, 2018 21:46
VERY IMPORTANT DOCUMENT! DO NOT ERASE!
bettyboop ꒰❛◑.◑❜꒱
blushh ꒰✿ᵕ‿ᵕ✿꒱
blusshh ꒰🔴ᵕ‿ᵕ🔴꒱
cryy ༼ ༎ຶ ෴ ༎ຶ༽
davidcaruso (•_•)( •_•)>⌐■-■ (⌐■_■)
derpp ◴_◶
drooll :Q____     |_____ |______
facepalmdouble (ლ̂‸ლ̂)
facepalmm (-‸ლ)
flipp (╯°□°)╯︵
@quephird
quephird / Add button.purs
Last active February 16, 2017 23:51
Just a silly experiment with `purescript-dom` to create a button and add it to the document body.
import Prelude
import Data.Maybe
import Data.Nullable
import DOM.HTML as h
import DOM.HTML.Document as hd
import DOM.HTML.Types as ht
import DOM.HTML.Window as w
import DOM.Node.Document as nd
import DOM.Node.Node as n
import DOM.Node.Types as nt
#version 3.7;
global_settings {
assumed_gamma 1.0
}
#include "colors.inc"
#include "functions.inc"
#include "shapes.inc"
#include "shapes2.inc"
#include "stones.inc"
Sound[
{{"A", 0.3}, {"G", 0.3}, {"F", 0.3}, {"G", 0.3}, {"A", 0.3}, {"A", 0.3}, {"A", 0.6},
{"G", 0.3}, {"G", 0.3}, {"G", 0.6}, {"A", 0.3}, {"C5", 0.3}, {"C5", 0.6},
{"A", 0.3}, {"G", 0.3}, {"F", 0.3}, {"G", 0.3}, {"A", 0.3}, {"A", 0.3},
{"A", 0.6}, {"G", 0.3}, {"G", 0.3}, {"A", 0.3}, {"G", 0.3}, {"F", 0.6}}
/. {p_, d_} :>
SoundNote[{p}, d, "Harpsichord"]]
class Lexer
KEYWORDS = ["def", "class", "if", "true", "false", "nil"]
IDENTIFIER_REGEX = /\A([a-z]\w*)/
CONSTANT_REGEX = /\A([A-Z]\w*)/
NUMBER_REGEX = /\A([0-9]+)/
STRING_REGEX = /\A"([^"]*)"/
NEW_BLOCK_REGEX = /\A\:\n( +)/m
INDENT_REGEX = /\A\n( *)/m
OPERATOR_REGEX = /\A(\|\||&&|==|!=|<=|>=)/