Skip to content

Instantly share code, notes, and snippets.

@dszakallas
dszakallas / a
Created November 10, 2023 08:37
a
@dszakallas
dszakallas / keybase.md
Created June 25, 2022 09:34
keybase.md

Keybase proof

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:

@dszakallas
dszakallas / fib.md
Last active April 3, 2018 23:54
Evolving a Fibonacci

We all know about the Fibonacci sequence. Some of us also know a song that uses it to achieve a spiraling feeling (yes, Tool fans!).

In Haskell:

fib 1 = 0
fib 2 = 1
fib x = fib (x - 1) (x - 2)
@dszakallas
dszakallas / ShortestPaths.md
Last active April 3, 2018 23:44
ShortestPaths.md

As a rookie Haskeller coming from imperative languages I am still often shocked how elegantly mathematical problems can be expressed in this great language. Last time a wrote a blogpost about recursion. As an example, I presented the Relation type and implemented an operation to it I called join. If you are familiar with relational algebra you might have recognized that this is a specific case of equijoin, where you join pairs so that the first pair's second element matches the second pair's first element. I was thinking about a more complex problem I could solve with this toolkit, one

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dszakallas
dszakallas / kleene.md
Last active February 10, 2018 14:39
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.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@dszakallas
dszakallas / coroutine.js
Last active February 1, 2018 20:35
Javascript Snippets
// 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
@dszakallas
dszakallas / Endless.md
Last active January 9, 2018 10:24
Java, Not even once

Endless streams

Disclaimer: This is a satire, and not meant to be taken any more seriously than Java itself. It is not about Java 8 streams. This satire just shows how easy is to define a very complex endless stream functionally in Java using lambdas.

In Scala:

def naturals: Stream[Int] = 0 #:: naturals.map(_ + 1)
@dszakallas
dszakallas / my_first_clojure_go_routine.clj
Created October 29, 2017 12:09
clojure.async examples
(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))))