Skip to content

Instantly share code, notes, and snippets.

View avh4's full-sized avatar

Aaron VonderHaar avh4

View GitHub Profile
@avh4
avh4 / scan.js
Created October 24, 2015 19:06
Find module dependencies in a haskell project
var fs = require('fs');
var map = {};
var seen = {};
function go(module, indent) {
if (!!seen[module]) return;
console.log(indent + module);
@avh4
avh4 / Main.elm
Last active October 24, 2015 05:39
Modeling a sliding puzzle
import Html exposing (..)
import Dict exposing (Dict)
type alias Board =
{ tiles : Dict (Int, Int) Int
, empty : (Int, Int)
}
newBoard =
@avh4
avh4 / gist:81c133f6b9d479e56fd0
Created July 11, 2015 22:57
Starting a node.js project

Requires

  • git
  • nodejs (npm)

Create the project:

PROJECT="my-project-name"
mkdir "$PROJECT"
@avh4
avh4 / 00 Original.java
Last active August 29, 2015 14:23
Cohesion / Coupling example 3
class Game {
int ballX = 0;
int ballY = 0;
int ballYSpeed = 3;
int paddleX = 30;
int paddleY = 500;
public void update() {
ballX = ballX + 5;
ballY = ballY + ballYSpeed;
@avh4
avh4 / 00 Original.java
Created June 21, 2015 21:03
Cohesion example 2
class Game {
int ballX = 0;
int ballY = 0;
public void draw(Graphics g) {
// draw the background
g.setColor(new Color(178, 223, 224));
g.fillRect(0, 0, 800, 600);
// draw the ball
@avh4
avh4 / 00 Original.java
Last active August 29, 2015 14:23
Cohesion example 1
class Game {
int ballX = 0;
int ballY = 0;
public void update() {
ballX = ballX + 5;
ballY = ballY + 5;
}
}
@avh4
avh4 / gist:15e5a9be3e6cff0cef01
Created June 10, 2015 20:21
parsing onClick location in Elm
import Json.Decode as Decode
decodeClickLocation : Decode.Decoder (Int,Int)
decodeClickLocation =
Decode.object2 (,)
(Decode.object2 (-)
(Decode.at ["pageX"] Decode.int)
(Decode.at ["target", "offsetLeft"] Decode.int)
)
(Decode.object2 (-)
-- Only works with Elm 0.15
import Html
import Task
import Port
import Debug
import Dict
import Time
-- MODEL
@avh4
avh4 / gist:a5adab664c19f60be992
Created January 11, 2015 19:21
Outline Zipper example
-- -- -- type definitions
type Outline = Outline
{ title : String
, description: String
, inbox : List Outline
, children : List Outline
}
type OutlineCrumb
@avh4
avh4 / gist:8997ef6a74c9da5a6e23
Created November 13, 2014 03:50
Detect the row under the mouse
import Color
import Mouse
e (col,text) = plainText text |> color col |> width 400
type Model = [(Color, String)]
model : Model
model =
[ (Color.red, "short")