I hereby claim:
- I am dszakallas on github.
- I am david_szakallas (https://keybase.io/david_szakallas) on keybase.
- I have a public key whose fingerprint is 38F9 8FCE 7CED FA3C 04D9 B6FE 9E63 257F 2A73 97BB
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
(ns my-first-clojure-go-routine | |
(:require [clojure.core.async :refer :all])) | |
(defn ping [name chan & [start?]] | |
(go (when start? (>! chan 0)) | |
(loop [i (<! chan)] | |
(println name i) | |
(>! chan (inc i)) | |
(if (< i 100) (recur (<! chan)) i)))) |
import scala.reflect.ClassTag | |
class FixedCapQueue[A: ClassTag](size: Int) { | |
val queue: Array[A] = new Array(size) | |
var start: Int = 0 | |
var end: Int = 0 | |
var empty = size > 0 | |
def take(): A = { | |
if (end == start && empty) throw new Exception("Queue empty") |
template<typename T> void f(T&& param); // param is now a universal reference | |
int x = 27; | |
const int cx = x; | |
const int& rx = x; | |
f(x); // x is lvalue, so T is int&, | |
// param's type is also int& | |
f(cx); // cx is lvalue, so T is const int&, | |
// param's type is also const int& | |
f(rx); // rx is lvalue, so T is const int&, | |
// param's type is also const int& |
/* | |
Immutable bidirectional multimap with unique set of values and keys. | |
*/ | |
case class BiMultiMap[K, V]( | |
forward: Map[K, Set[V]] = Map.empty, | |
backward: Map[V, Set[K]] = Map.empty | |
) { | |
import BiMultiMap._ | |
def +(kv: (K, Set[V])): BiMultiMap[K, V] = { | |
val (nextForward, nextBackward) = kv match { |
Recently I've been writing a graph query engine at Fault Tolerant System Research Group at uni. The frontend is Cypher, a language popularized by Neo Technology shipped OOTB with their graph database Neo4j.
Recently Cypher is getting standardized in an open source and open government initiative under the name openCypher; and other DB vendors, such as the RDBMS giant Oracle are starting to support it.
The language itself is similar to SQL augmented with syntax for graph pattern matching. One of the similarities is the handling of NULL values.
/* Copyright 2017 David Szakallas, MIT License */ | |
import simulacrum.{op, typeclass} | |
@typeclass trait GenKleeneLike[-A] { | |
@op("|=|") def eq(x: A, y: A): Option[Boolean] | |
@op("|!|") def ne(x: A, y: A): Option[Boolean] | |
} | |
object GenKleeneLike { | |
class GenKleeneLikeForOption[Opt <: Option[Any]] extends GenKleeneLike[Opt] { | |
override def eq(x: Opt, y: Opt): Option[Boolean] = |
Abstract: Blogpost summarizing the challenges of creating a flexible and customizable MIDI controller mapping for Mixxx targeting multiple Novation Launchpad grid controllers.
Keywords: JavaScript, MIDI, Mixxx, ES6 modules, Babel, Flow
I own two Novation Launchpads. The most iconic use-cases of this cool grid controller is launching samples. Launchpad cover videos are very popular on YouTube. These are done by slicing up the songs, and playing back live, spiced with some flashy visual effects.
You can also use launchpads for DJing. While being fit for a handful of things: cueing samples, beatjumping and looping, etc.; the Launchpad have neither a jogwheel nor any rotary controls or faders, so it falls short on functions like scratching or crossfading. Thus, it’s best to use as companion to your other DJ gear.
// Turn a generator function into a coroutine | |
const coroutine = (f) => (...args) => { | |
const g = f(...args) // instantiate the generator | |
const iter = ({ done, value }) => done // iterate over suspensions | |
? value | |
: value.then( | |
(d) => iter(g.next(d)), | |
(e) => iter(g.throw(e)) | |
) | |
return Promise.resolve().then(() => iter(g.next())) // start iterating asynchronously |