Skip to content

Instantly share code, notes, and snippets.

@dtoma
dtoma / taoup.md
Created January 16, 2019 07:15
The Art of Unix Programming

https://arp242.net/the-art-of-unix-programming/

More of the Unix philosophy was implied not by what these elders said but by what they did and the example Unix itself set. Looking at the whole, we can abstract the following ideas:

Rule of Modularity: Write simple parts connected by clean interfaces. Rule of Clarity: Clarity is better than cleverness. Rule of Composition: Design programs to be connected to other programs. Rule of Separation: Separate policy from mechanism; separate interfaces from engines. Rule of Simplicity: Design for simplicity; add complexity only where you must. Rule of Parsimony: Write a big program only when it is clear by demonstration that nothing else will do.

@dtoma
dtoma / dispatch.py
Created January 4, 2019 10:04
python single dispatch
from functools import singledispatch
class Foo:
pass
class Bar(Foo):
pass
class Baz(Foo):
pass
#include <fstream>
#include <iostream>
#include "kaitai/kaitaistream.h"
#include "exif_le.h"
#include "exif.h"
#include "jpeg.h"
#include <map>
#include <string>
@dtoma
dtoma / bench.cpp
Created December 7, 2018 09:14
Bench lib c++
/* Simple benchmarking library
- Run `f()` in increasing batch sizes
- report the estimated time of `f()` by doing a linear regression
- Output a vega-lite JSON file for visualization
Inspiration:
- https://blog.janestreet.com/core_bench-micro-benchmarking-for-ocaml/
- http://www.serpentine.com/blog/2009/09/29/criterion-a-new-benchmarking-library-for-haskell/
- https://vega.github.io/vega-lite/examples/bar.html
*/
@dtoma
dtoma / elm.md
Last active November 1, 2018 14:13
Notes on ELM

Elm HTML nodes: element [attributes] [children], example: h1 [] [text "My Title"]


  +------> Model -----+
  |                   |
  |                   |
Update                v
  ^                 View
 | |
@dtoma
dtoma / streaming-charts.md
Created October 4, 2018 09:03
Streaming chart using websockets
<!DOCTYPE html>
<html>
    <head>
        <title>WebSocket demo</title>
    </head>
    <body>
        <div style="width: 600px; height: 800px;"><canvas id="myChart"></canvas></div>

        <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.22.2/moment.min.js"></script>
@dtoma
dtoma / map.html
Last active September 16, 2018 01:58
map
<!DOCTYPE html>
<meta charset="utf-8"> <meta name="viewport" content="width=device-width">
<body>
<script src="https://d3js.org/d3.v3.min.js"></script>
<script src="https://d3js.org/topojson.v1.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/datamaps/0.5.8/datamaps.all.js"></script>
<div id="pnlmap" style="height: 100%; width: 100%;"></div>
<script>
@dtoma
dtoma / Install.md
Created October 20, 2017 06:20
Install checklist
  • git
  • tmux
  • font: SourceCodePro
  • emacs + plugins for python/git
  • Jupyter
@dtoma
dtoma / haskell98.hs
Created April 13, 2017 07:15
A gentle introduction to haskell 98
-- A gentle introduction to Haskell 98
import Test.QuickCheck
import Data.List
----------------------------------------------
-- Chapter 2: Values, Types, and Other Goodies
data Tree a = Leaf a | Branch (Tree a) (Tree a)