Skip to content

Instantly share code, notes, and snippets.

@yminsky
yminsky / gist:1645d897bc9128ed4450
Created Dec 5, 2015
Lyrics for OCaml/Async rap
View gist:1645d897bc9128ed4450
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
View gist:8773a39663332ef00a50
#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 Jun 19, 2015
Plotting sine and cosine with c3 and js_of_ocaml
View Plotting sine and cosine with c3 and js_of_caoml
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 Apr 19, 2015
This one sounds worse, but is non-blocking
View gist:f98996143e4631eb739b
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 Apr 19, 2015
The code that sounds good.
View gist:544fc49c6d9a932ba424
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 Apr 11, 2015
A better failure building implicit...
View gist:1f8d17fb639a111c54eb
~ $ 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...
View gist:6082664b3ea074424c46
~ $ 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 Apr 11, 2015
Attempt to Cabal install "implicit"
View gist:5accb38dee5ce7b59e52
~ $ \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.
View gist:26d09128aec06d505e0a
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
View gist:ef29c8661dae7a011ce1
$ 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)
You can’t perform that action at this time.