Skip to content

Instantly share code, notes, and snippets.

Fredrik Dyrkell fredyr

Block or report user

Report or block fredyr

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
View params.py
import inspect
from urllib.parse import urlparse
class ParameterSet:
pass
class Field:
def __init__(self, description, **kwargs):
@fredyr
fredyr / binaryclock.re
Created Mar 19, 2017
Binary clock using Reason/React
View binaryclock.re
type bitnum = (int, list bool);
let elem_of_list ls => ReactRe.arrayToElement (Array.of_list ls);
let text s => ReactRe.stringToElement s;
let cell_col bit => {
let color = if bit {"light"} else {"dark"};
<div className=("cell " ^ color) />
};
@fredyr
fredyr / npm-debug.log
Created Feb 19, 2017
npm install fails on ReasonProject
View npm-debug.log
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli '/usr/local/bin/npm',
1 verbose cli '--verbose',
1 verbose cli 'install' ]
2 info using npm@4.1.2
3 info using node@v7.5.0
4 silly loadCurrentTree Starting
5 silly install loadCurrentTree
6 silly install readLocalPackageData
View where.el
(defmacro lwt (&rest args)
(destructuring-bind (b1 wh b2 &rest body) args
`(let* (,@b2 ,@b1) ,@body)))
(macroexpand-all
'(lwt ((w (* x y)))
:where
((x 2)
(y 3))
(+ 1 w)))
View where.el
(defmacro lwt (&rest args)
(destructuring-bind (b1 wh b2 &rest body) args
`(let* (,@b2 ,@b1) ,@body)))
(macroexpand-all
'(lwt ((w (* x y)))
:where
((x 2)
(y 3))
(+ 1 w)))
@fredyr
fredyr / biquad.ml
Created Jan 4, 2016
Tiny biquad filter
View biquad.ml
(*
Tiny Biquad filter implementation in OCaml.
Ported straight from http://www.musicdsp.org/files/biquad.c
*)
type biquad = {
a0 : float;
a1 : float;
a2 : float;
a3 : float;
View tree.ex
# center a string s on position c
# cent("0", 5) => " 0 "
# cent("000", 5) => " 000 "
# but we ignore right side spaces
cent = fn(s, c) ->
String.duplicate(" ", div(c - String.length(s), 2)) <> s
end
# piping through partials?
# SAAD PUPPY :'(
View goertzel.py
import math
import numpy
import matplotlib.pyplot as plt
def sine(frequency, length, rate):
length = int(length * rate)
factor = float(frequency) * (math.pi * 2) / rate
return numpy.sin(numpy.arange(length) * factor)
View intro-to-ocaml.ml
(*
INTRODUCTION TO OCAML
Fredrik Dyrkell
@lexicallyscoped
www.lexicallyscoped.com
View learningocaml.md

Learning OCaml

Similarly to what exists for Haskell, I wanted to make a curated collection of good resources for getting started with OCaml.

Installation and getting started

Follow the installation instructions from the Real World OCaml book available here. This will get you accustomed to

  • Opam, the package manager, which also gives to the possibility of switching between OCaml versions.
  • Utop, a modern interactive toplevel
  • Set up of your enviroment, in particular #use "topfind" so that Utop finds your packages installed by Opam.
You can’t perform that action at this time.