Skip to content

Instantly share code, notes, and snippets.

@dtoma
dtoma / ringbuffer.cpp
Created February 24, 2017 08:17
ringbuffer
#include <array>
#include <iostream>
#include <iomanip>
namespace {
template <typename T, std::size_t N>
auto print_array(std::array<T, N> a) {
std::cout << "array: |";
for (auto const& e : a) {
std::cout << std::setw(2) << e << "|";
@dtoma
dtoma / ini.cpp
Created March 24, 2017 08:43
ini configuration reader
#include <algorithm>
#include <optional>
#include <type_traits>
#include <unordered_map>
#include <vector>
#include <cstdio>
// http://tristanbrindle.com/posts/a-quicker-study-on-tokenising/
template <typename Iterator, typename Lambda>
@dtoma
dtoma / tt.cpp
Created April 7, 2017 03:40
tuples types
#include <tuple>
// Macro to declare elements of an `enum class`
#define DEFINE_ENUM_TYPE(type, id) type = id,
// Declare currencies
#define CURRENCIES(code) \
code(USD, 0) \
code(EUR, 1)
@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)
@dtoma
dtoma / Install.md
Created October 20, 2017 06:20
Install checklist
  • git
  • tmux
  • font: SourceCodePro
  • emacs + plugins for python/git
  • Jupyter
@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 / 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 / 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 / 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
*/
#include <fstream>
#include <iostream>
#include "kaitai/kaitaistream.h"
#include "exif_le.h"
#include "exif.h"
#include "jpeg.h"
#include <map>
#include <string>