Skip to content

Instantly share code, notes, and snippets.

Jason Merrill jwmerrill

Block or report user

Report or block jwmerrill

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@jwmerrill
jwmerrill / preview.md
Last active Dec 2, 2016
Desmos API v0.8 release preview
View preview.md

As part of our scheduled release cycle, version 0.8 of the Desmos API will be released as the new stable version this month. It is currently available for preview, and this is a great time to check out the new features that will become available. We'd love to hear your feedback.

In version 0.8, we are introducing three major new capabilities to the API, all designed to make the calculator more accessible to more users:

  1. The calculator is now accessible to screen readers, and has been updated to comply with the WCAG 2.0 accessibility standard. When a screen reader is active, math expressions are read aloud as you navigate and edit them, and plotted curves can be played as audio or have the coordina
@jwmerrill
jwmerrill / resizable-yogi.elm
Last active May 6, 2016
Updated version of Elm's resizable yogi
View resizable-yogi.elm
import Html exposing (..)
import Html.App as Html
import Html.Attributes exposing (..)
import Html.Events exposing (..)
import Mouse
main =
Html.program
{ init = (Model 200, Cmd.none)
, view = view
@jwmerrill
jwmerrill / reinterpret
Created Nov 9, 2015
Float int cast native code
View reinterpret
julia> function fn(x1::Float64, x2::Float64)
x1_int = reinterpret(UInt64, x1)
x2_int = reinterpret(UInt64, x2)
reinterpret(Float64, (x1_int + x2_int) >> 1)
end
fn (generic function with 1 method)
julia> @code_native fn(3.0, 4.0)
.section __TEXT,__text,regular,pure_instructions
Filename: none
@jwmerrill
jwmerrill / DigitSets.jl
Created Oct 21, 2015
Efficient representation of a set of digits 1-9
View DigitSets.jl
# Represent a set of digits 1-9 as an Int16, where the binary digits of the
# integer form a mask determining whether the associated digit is present in
# the set
immutable DigitSet
d::Int16
end
function DigitSet(a::AbstractArray)
d = Int16(0)
for n in a
View gist:a40a0330e3094d473245
GC(T+97773.6) Reason: TOO_MUCH_MALLOC, Total Time: 16.9ms, Zones Collected: 1, Total Zones: 30, Total Compartments: 417, Minor GCs: 2, Store Buffer Overflows: 0, MMU (20ms): 15%, MMU (50ms): 66%, SCC Sweep Total: 0.3ms, SCC Sweep Max Pause: 0.3ms, Nonincremental Reason: malloc bytes trigger, Allocated: 178MB, +Chunks: 0, -Chunks: 0
Totals:
The connection to http://jsbin.com/piyeye/1?0.44316687606709093 was interrupted while the page was loading. spike.js:232:0
GC(T+97775.4) Reason: TOO_MUCH_MALLOC, Total Time: 26.6ms, Zones Collected: 1, Total Zones: 32, Total Compartments: 420, Minor GCs: 3, Store Buffer Overflows: 0, MMU (20ms): 0%, MMU (50ms): 46%, SCC Sweep Total: 0.5ms, SCC Sweep Max Pause: 0.5ms, Nonincremental Reason: malloc bytes trigger, Allocated: 179MB, +Chunks: 0, -Chunks: 0
Totals:
GC(T+97777.0) Max Pause: 37.6ms, Total Time: 309.2ms, Zones Collected: 32, Total Zones: 32, Total Compartments: 420, Minor GCs: 25, Store Buffer Overflows: 0, MMU (20ms): 0%, MMU (50ms): 16%, SCC Sweep Total:
View gist:0a5fe94854e570cfc540
jwm@jason ~/s/elm-platform> runhaskell src/BuildFromSource.hs master
Writing a default package environment file to
/Users/jwm/src/elm-platform/Elm-Platform/master/cabal.sandbox.config
Creating a new sandbox at /Users/jwm/src/elm-platform/Elm-Platform/master
Cloning into 'elm-compiler'...
remote: Counting objects: 17753, done.
remote: Compressing objects: 100% (100/100), done.
remote: Total 17753 (delta 56), reused 0 (delta 0)
Receiving objects: 100% (17753/17753), 5.44 MiB | 1.20 MiB/s, done.
Resolving deltas: 100% (10044/10044), done.
View elm-runtime-updated.js
'use strict';
var Elm = {}; Elm.Native = {}; Elm.Native.Graphics = {};
var ElmRuntime = {}; ElmRuntime.Render = {};
Elm.Native.Array = {};
Elm.Native.Array.make = function(elm) {
elm.Native = elm.Native || {};
elm.Native.Array = elm.Native.Array || {};
if (elm.Native.Array.values) return elm.Native.Array.values;
if ('values' in Elm.Native.Array)
return elm.Native.Array.values = Elm.Native.Array.values;
@jwmerrill
jwmerrill / elm-runtime.diff
Last active Aug 29, 2015
Modification of elm's runtime to allow drawing more consistently at 60 fps
View elm-runtime.diff
9345,9351c9345,9374
- var previousDrawId = 0;
- function domUpdate(newScene) {
- previousDrawId = ElmRuntime.draw(previousDrawId, function(_) {
- Render.update(elm.node.firstChild, savedScene, newScene);
- if (elm.Native.Window) elm.Native.Window.values.resizeIfNeeded();
- savedScene = newScene;
- });
+
+ // domUpdate is called whenever the main Signal changes. On domUpdate,
@jwmerrill
jwmerrill / graythresh_kmeans.jl
Created Nov 10, 2014
Kmeans thresholding of a grayscale image
View graythresh_kmeans.jl
function graythresh_kmeans(img)
# Note, without the type annotation, this is slow because
# mean appears not to be type stable here
thresh = mean(img)::Gray{Float32}
while true
lastthresh = thresh
nplus = 0
nminus = 0
splus = zero(typeof(thresh))
@jwmerrill
jwmerrill / viterbi_2.jl
Created Sep 21, 2014
Viterbi algorithm
View viterbi_2.jl
const states = ["Healthy", "Fever"]
const obsnames = ["normal", "cold", "dizzy"]
const start_probability = [0.6, 0.4]
const transition_probability = [
0.7 0.3
0.4 0.6
]
You can’t perform that action at this time.