Skip to content

Instantly share code, notes, and snippets.

View astrieanna's full-sized avatar
⛰️
working from home

Leah Hanson astrieanna

⛰️
working from home
View GitHub Profile
@astrieanna
astrieanna / squares.elm
Created September 21, 2014 20:22
modified version of http://elm-lang.org/edit/examples/Elements/Lines.elm (the red square follows the mouse)
import Mouse
# Separating main and squares was key to making lift work
# I don't know how to convert Signal (Int,Int) to Signal (Float,Float)
# so I separated x and y into different arguments
main = lift2 squares (toFloat <~ Mouse.x)
(toFloat <~ Mouse.y)
squares : Float -> Float -> Element
squares x y =
@astrieanna
astrieanna / cube.elm
Created September 21, 2014 23:44
modified version of http://elm-lang.org/edit/examples/WebGL/Cube.elm left-right movement of mouse controls cube rotation
import Math.Vector3 (..)
import Math.Matrix4 (..)
import Graphics.WebGL (..)
import Mouse
-- Create a cube in which each vertex has a position and color
type Vertex = { color:Vec3, position:Vec3 }
@astrieanna
astrieanna / mlemming.elm
Last active August 29, 2015 14:07
Mario has visible platforms (multiple!) that he runs into, sorta. He also walks like a lemming.
import Keyboard
import Window
-- MODEL
type Lemming = {x:Int, y:Int, vx:Float, vy:Float, dir:String, onSurface:Bool}
mario1:Lemming
mario1 = { x=20, y=900, vx=0, vy=0, dir="right", onSurface=False }
mario2:Lemming
mario2 = { x=60, y=900, vx=0, vy=0, dir="right", onSurface=False }
allMarios = [mario1, mario2]
@astrieanna
astrieanna / CodeTypeSample.ipynb
Created March 13, 2015 01:41
Using the output of code_typed
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@astrieanna
astrieanna / draft.asciidoc
Created April 6, 2015 20:56
NetCDF section for Learning Julia (with full script); not planning to include in book

Writing a Parser

Our goal for this section is to parse a NetCDF file. NetCDF is a binary format, which is most often used for climatology/geoscience data. Because it is a custom binary format, we’re going to write a custom parser for it by hand.

Tip

If you have a format based on JSON or XML to parse, then you should start with JSON.jl or julia-xml-library, rather than writing it by hand.

@astrieanna
astrieanna / fingertree.rs
Created March 12, 2013 19:20
The file that makes rustc have an "unexpected failure" and the resulting log.
enum FingerTree<A> { Empty
, Single(A)
, Deep (Digit<A>, @FingerTree<Node<A>>, Digit<A>)
}
enum Node<A> { Node2(A,A), Node3(A,A,A) }
enum Digit<A> { One(A)
, Two(A,A)
, Three(A,A,A)
, Four(A,A,A,A)
@astrieanna
astrieanna / freezes.jl
Created March 14, 2013 23:38
Socket code in Julia.
echo2_helper(socket,stat) =
begin
println(stat)
show(socket)
c = accept(socket)
println(c)
line = read_line(c)
println(line)
while line != "0\n"
write(c,line)
@astrieanna
astrieanna / bitmapped-vector-trie.rs
Created March 20, 2013 16:27
A file that makes rustc have an internal error (task failed at 'Unsupported constant expr') and the backtrace log from the compiler. The file compile.log was created using `rustc bitmapped-vector-trie.rs --test &> compile.log`.
struct Level1<A> {
data : @mut [@A * 5]
, mut current : int
}
struct Level2<A> {
data : @mut [@Level1<A> * 32]
, mut current : int
}
@astrieanna
astrieanna / make.log
Last active December 15, 2015 05:59
Output of make on failed build of Servo.
make[1]: Entering directory `/home/leah/code/servo/build/src/pixman'
make all-recursive
make[2]: Entering directory `/home/leah/code/servo/build/src/pixman'
Making all in pixman
make[3]: Entering directory `/home/leah/code/servo/build/src/pixman/pixman'
make[3]: Nothing to be done for `all'.
make[3]: Leaving directory `/home/leah/code/servo/build/src/pixman/pixman'
Making all in demos
make[3]: Entering directory `/home/leah/code/servo/build/src/pixman/demos'
make[3]: Nothing to be done for `all'.
configure: looking for configure programs
configure: found cmp
configure: found mkdir
configure: found printf
configure: found cut
configure: found grep
configure: found xargs
configure: found cp
configure: found find
configure: found uname