Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@yminsky
yminsky / gist:1645d897bc9128ed4450
Created December 5, 2015 17:05
Lyrics for OCaml/Async rap
Lyrics:
Take big steps to eval, like a nomad
Bind and return like a Monad
Got you looking so mad
about the signature I got you using
in the directory with the MLI files the compiler was choosing
The type checks out, I’m feeling greater
Defer the value now and I return a little later
Cuz I’m threaded, so for now I ain’t got much to say
#lang racket
(require web-server/servlet
web-server/servlet-env)
(require pict)
(require file/convertible)
(require xml)
(define (pict->svg pict)
(define svg-b (convert pict 'svg-bytes))
@yminsky
yminsky / Plotting sine and cosine with c3 and js_of_caoml
Created June 19, 2015 02:33
Plotting sine and cosine with c3 and js_of_ocaml
let get_by_id id =
let d = Dom_html.document in
Js.Opt.get (d##getElementById (Js.string id))
(fun () -> assert false)
let rec range i n =
if i >= n then [] else i :: range (i + 1) n
let base =
range 0 100
@yminsky
yminsky / gist:f98996143e4631eb739b
Created April 19, 2015 22:49
This one sounds worse, but is non-blocking
void play_note(long tone, long start, long now) {
long gap = now - start;
long step = gap / tone;
boolean high = (step % 2 == 0);
if (high) { digitalWrite(speaker_pin, HIGH); }
else { digitalWrite(speaker_pin,LOW); }
}
@yminsky
yminsky / gist:544fc49c6d9a932ba424
Created April 19, 2015 22:47
The code that sounds good.
void playTone(int tone, int duration) {
for (long i = 0; i < duration * 1000L; i += tone * 2) {
digitalWrite(speakerPin, HIGH);
delayMicroseconds(tone);
digitalWrite(speakerPin,LOW);
delayMicroseconds(tone);
}
}
@yminsky
yminsky / gist:1f8d17fb639a111c54eb
Created April 11, 2015 19:59
A better failure building implicit...
~ $ cabal install implicit
Resolving dependencies...
Downloading Boolean-0.2.3...
Downloading NumInstances-1.4...
Configuring Boolean-0.2.3...
Downloading ansi-terminal-0.6.2.1...
Configuring NumInstances-1.4...
Downloading byteorder-1.0.4...
Configuring ansi-terminal-0.6.2.1...
Downloading mtl-2.1.3.1...
@yminsky
yminsky / gist:6082664b3ea074424c46
Created April 11, 2015 19:36
Now trying pandoc
~ $ cabal install pandoc
Resolving dependencies...
cabal: Could not resolve dependencies:
trying: pandoc-1.13.2 (user goal)
trying: base-4.8.0.0/installed-901... (dependency of pandoc-1.13.2)
next goal: haddock-library (dependency of pandoc-1.13.2)
rejecting: haddock-library-1.2.0 (conflict: pandoc => haddock-library>=1.1 &&
<1.2)
rejecting: haddock-library-1.1.1, 1.1.0 (conflict:
base==4.8.0.0/installed-901..., haddock-library => base>=4.3 && <4.8)
@yminsky
yminsky / gist:5accb38dee5ce7b59e52
Created April 11, 2015 19:34
Attempt to Cabal install "implicit"
~ $ \rm -rf .cabal
~ $ cabal install implicit
Config file path source is default config file.
Config file /Users/yminsky/.cabal/config not found.
Writing default configuration to /Users/yminsky/.cabal/config
Warning: The package list for 'hackage.haskell.org' does not exist. Run 'cabal
update' to download it.
cabal: There is no package named 'implicit'.
You may need to run 'cabal update' to get the latest list of available
packages.
Downloading semigroups-0.16.2.2...
Configuring semigroups-0.16.2.2...
Building semigroups-0.16.2.2...
Preprocessing library semigroups-0.16.2.2...
src/Data/Semigroup.hs:105:8:
Ambiguous module name ‘Numeric.Natural’:
it was found in multiple packages:
nats-0.1.2@nats_1SlQ91QfEGVBnpiEUJoePq base-4.8.0.0
Failed to install semigroups-0.16.2.2
$ opam config report
# OPAM status report
# opam-version 1.2.0
# self-upgrade no
# os darwin
# external-solver aspcud
# criteria -count(removed),-notuptodate(request),-count(down),-notuptodate(changed),-count(changed),-notuptodate(solution)*
# jobs 6
# repositories 1* (http)
# pinned 1 (path)