Skip to content

Instantly share code, notes, and snippets.

@drathier
drathier / Main.elm
Last active June 29, 2019 13:34 — forked from owanturist/Main.elm
type FrontendMsg
= FNoop
| Increment
| Decrement
| OnBackendMsg ToFrontend
update : FrontendMsg -> Model -> ( Model, Cmd FrontendMsg )
update msg model =
case msg of
FNoop ->
@drathier
drathier / new
Created July 18, 2017 12:11
https://github.com/elm-community/elm-test/pull/184 benchmarks on mid-2009 MBP, osx 10.11.6, 2x2.26GHz, 8GB ram
Benchmark Finished
Group: Fuzz
Group: int
Benchmark: generating
mean ops/sec 110,107.98 (stddev: 4,621.47, 4.2%)
mean runtime 9.097ns (stddev: 370.074µs, 4.07%)
module Fact.Base64 exposing (..)
{-| Decode/encode base64 strings to/from ints.
-}
import Bitwise
import Char
import List.Extra
@drathier
drathier / elm-test-pycharm-runner.py
Created March 16, 2017 18:47
A Python script that runs elm-test, so you can elm-test without leaving PyCharm
import subprocess
import sys
import os
try: # windows
x = subprocess.run([os.environ['USERPROFILE'] + r"\AppData\Roaming\npm\elm-test.cmd"], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
except: # macos / linux
x = subprocess.run([r"/usr/local/bin/elm-test"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
@drathier
drathier / elm-test-128-simulation.py
Created February 22, 2017 12:00
Elm-test #128 regression bug detection rate simulation
import random
for twenty in [3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 17, 20, 22, 25, 27, 30, 33, 37, 40, 44, 50, 54, 60, 64, 70, 74, 80, 84, 90, 94, 100]:
print("#" * 10)
print("twenty", twenty)
n = 10 ** 6
found = 0
for k in range(n):
# Elixir, functional (one understandable, and one fast version)
defmodule Flat do
# Easy to read, preferred for small input. O(length*depth)
def flatten([[a]]), do: flatten([a])
def flatten([a]), do: [a]
def flatten([a|bs]), do: flatten(a) ++ flatten(bs)
# Linear time, a bit harder to read if you're not used to
# high-performant functional programming. O(length+depth)
def flatfast(a), do: reverse flatfast(a, [])
@drathier
drathier / # cputhrottle - 2016-05-07_19-18-45.txt
Created May 7, 2016 17:24
cputhrottle on Mac OS X 10.11.4 - Homebrew build logs
Homebrew build logs for cputhrottle on Mac OS X 10.11.4
Build date: 2016-05-07 19:18:45