Skip to content

Instantly share code, notes, and snippets.

View erikvullings's full-sized avatar

Erik Vullings erikvullings

View GitHub Profile
@erikvullings
erikvullings / README.md
Last active August 29, 2015 14:14
Grouped horizontal bar chart.

This is an example of a horizontally grouped bar chart. It allows you to easily see the difference between different series of data.

@erikvullings
erikvullings / ColorExt.js
Created October 13, 2015 22:01
Displaying an ESRI ASCII grid file in leaflet using an HTML5 canvas element.
var ColorExt;
(function (ColorExt) {
var Utils = (function () {
function Utils() {
}
Utils.hsv2rgb = function (h, s, v) {
var rgb, i, data = [];
if (s === 0) {
rgb = [v, v, v];
}
@erikvullings
erikvullings / index.html
Last active July 4, 2018 08:41
Horizontal axis with major and minor ticks using d3 version 4.
<!--
Source: https://gist.github.com/erikvullings/41be28677574fd484b43e91413a7e45d
Preview: https://bl.ocks.org/erikvullings/41be28677574fd484b43e91413a7e45d
-->
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<script src="https://d3js.org/d3.v4.min.js"></script>
<style>
@erikvullings
erikvullings / 0_reuse_code.js
Created May 8, 2017 11:32
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@erikvullings
erikvullings / scheduler.exs
Created August 9, 2017 14:20
Elixir scheduler example
# Example of a simple scheduler in Elixir
# Source code from the book Programming Elixir
# See: https://pragprog.com/book/elixir/programming-elixir
#
# Start iex
# $ iex
# > c("scheduler.exs")
# > Scheduler.run(12, FibSolver, :fib, [38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38, 38])
defmodule Scheduler do
@erikvullings
erikvullings / fib_agent.exs
Created August 9, 2017 14:35
Fast Fibonacci implementation in Elixir
# Fast Fibonacci implementation (using a Map to cache previous results)
# This code comes from a mailing-list post by José Valim.
#
# Run iex
# $ iex
# > c("fib_agent.exs")
# > { :ok, agent } = FibAgent.start_link()
# > IO.puts FibAgent.fib(agent, 38)
defmodule FibAgent do
@erikvullings
erikvullings / gist:8e8d5ae026748681de8ddde90d835cde
Created August 11, 2017 09:30
Starting a new phoenix application
# Phoenix, by default, uses a Postgres database, so start one via docker
docker pull postgres
# Expose it on port 8432
docker run -p 8432:5432 --name hello-postgres -e POSTGRES_PASSWORD=postgres -d postgres
# Install Erlang, Elixir, and now Phoenix
mix archive.install https://github.com/phoenixframework/archives/raw/master/phx_new.ez
# Create a new Phoenix app
mix phx.new hello
# Edit config/dev.exs and update your hostname. Add a port (default is 5432, but I've mapped it to 8432)
@erikvullings
erikvullings / docker-compose.yml
Created September 13, 2017 10:16
Docker-compose file for Kafka
---
version: '2'
services:
zookeeper:
image: confluentinc/cp-zookeeper
hostname: zookeeper
extra_hosts:
- "moby:127.0.0.1"
ports:
- "2181:2181"
@erikvullings
erikvullings / walk.ts
Last active April 14, 2022 14:23
Recursively walk a directory in TypeScript
import fs from 'fs';
import path from 'path';
/**
* Recursively walk a directory asynchronously and obtain all file names (with full path).
*
* @param dir Folder name you want to recursively process
* @param done Callback function, returns all files with full path.
* @param filter Optional filter to specify which files to include,
* e.g. for json files: (f: string) => /.json$/.test(f)
@erikvullings
erikvullings / geo.ts
Last active May 29, 2018 15:49
Convert RD (rijksdriehoek) to WGS84 and back.
/**
* Convert RD (Rijksdriehoek) coordinates to WGS84 and vice versa.
* @see https://thomasv.nl/2014/03/rd-naar-gps/
*/
const projectionBetweenRdWgs84 = () => {
const x0 = 155000;
const y0 = 463000;
const f0 = 52.15517440; // f => phi
const l0 = 5.38720621; // l => lambda