Skip to content

Instantly share code, notes, and snippets.


Dávid Szakállas dszakallas

View GitHub Profile
View null.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View my_first_clojure_go_routine.clj
(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))))
View fixedCapQueue.scala
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")
dszakallas / universal.cpp
Created Jul 12, 2017
universal reference
View universal.cpp
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&
dszakallas / BidirectionalMultiMap.scala
Last active Jun 30, 2017
View BidirectionalMultiMap.scala
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 {
dszakallas /
Last active Feb 10, 2018
Kleene blogpost

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.

View KleeneWithTypeClasses.scala
/* 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] =
dszakallas /
Last active Sep 6, 2017
Modern JavaScripting a MIDI controller

Modern JavaScripting a MIDI controller

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.

dszakallas / coroutine.js
Last active Feb 1, 2018
Javascript Snippets
View coroutine.js
// 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(,
(e) => iter(g.throw(e))
return Promise.resolve().then(() => iter( // start iterating asynchronously
dszakallas / rng.hs
Created Feb 11, 2017
View rng.hs
{-# LANGUAGE NoImplicitPrelude #-}
module Rng where
import GHC.Show (Show)
import GHC.Base (Eq, ($))
import GHC.Num ((*), (+), Integer)
import GHC.Float (Float, Double)
import GHC.Real (fromIntegral, (/))
import GHC.Enum (maxBound)
import Data.Int (Int64, Int32, Int16, Int8)
You can’t perform that action at this time.