Skip to content

Instantly share code, notes, and snippets.

Rüdiger Klaehn rklaehn

Block or report user

Report or block rklaehn

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@rklaehn
rklaehn / merge_sorted.rs
Last active Oct 30, 2019
Merge 2 sorted iterators
View merge_sorted.rs
use std::iter::{Iterator, Peekable};
pub struct MergeSorted<A: Iterator, B: Iterator> {
a: Peekable<A>,
b: Peekable<B>,
}
impl<A: Iterator, B: Iterator> MergeSorted<A, B> {
fn new(a: A, b: B) -> MergeSorted<A, B> {
MergeSorted {
View benchmark.js
let msgpackLite = require('msgpack-lite');
let borc = require('borc');
let _ = require('lodash');
let { performance } = require('perf_hooks')
let arrays = _.times(100, (n) => {
return _.times(n, i => ({ i, a: [String(i * 1234), String(i * 1234), String(i * 1234), String(i * 1234)] }))
});
let encodedBORC = arrays.map(array => borc.encode(array));
@rklaehn
rklaehn / Results
Last active Oct 8, 2018
CBOR encoding performance
View Results
$ node benchmark2.js
= Encoding Time (ms) =
msgp.encode 9172.339491000399
borc.encode 20400.477496000007
json.stringify 9445.365290999413
= Decoding Time (ms) =
msgp.decode 121.99922000057995
borc.decodeFirst 383.22095499932766
json.parse 48.20755399949849
View constructor.ts
const enum Test { a = 'a' }
type Protocol = {
foo: { x: string };
bar: { y: number };
}
type WithTag<T> = {
[TKey in keyof T]: { type: TKey } & T[TKey]
}
type ToDiscriminatedUnion<P> = WithTag<P>[keyof P]
type Constructor<T> = {
View match.ts
type Protocol = {
foo: { x: string };
bar: { y: number };
}
type Fold<T, U> = {
readonly [P in keyof T]: (value: T[P]) => U
}
type WithTag<T> = {
[TKey in keyof T]: { type: TKey } & T[TKey]
}
@rklaehn
rklaehn / ipfs-publish-remote.sh
Last active Jul 23, 2019
Publishing to ipfs/ipns by key
View ipfs-publish-remote.sh
#!/bin/bash
if [ "$#" -ne 3 ]; then
echo "usage:"
echo " ipfs-publish-remote.sh <keyname> <dir> <host>"
echo " example: ipfs-publish-remote.sh keyname output/rootdir user@ipfs.company.net"
exit 1
fi
KEYNAME=$1
DIR=$2
HOST=$3
View keybase.md

Keybase proof

I hereby claim:

  • I am rklaehn on github.
  • I am rklaehn (https://keybase.io/rklaehn) on keybase.
  • I have a public key ASD7KkefWWOcjAZuq_IdyTzpXYnoZAdKoouzRSU_Ul25qwo

To claim this, I am signing this object:

View UploadHandler.scala
package akkahttptest
import akka.actor.ActorSystem
import akka.http.scaladsl.Http
import akka.http.scaladsl.server.Route
import akka.stream.ActorMaterializer
import akka.http.scaladsl.server.Directives._
object UploadHandler extends App {
View dependencyTree
rklaehn@rklaehn-hp:~/projects_git/satmon3$ sbt satmonjavaservices/dependencyTree
[info] Loading project definition from /home/rklaehn/projects_git/satmon3/project
[info] Set current project to satmon3 (in build file:/home/rklaehn/projects_git/satmon3/)
[info] heavens-above:satmonjavaservices_2.11:3.1.75_33302eb [S]
[info] +-com.google.protobuf:protobuf-java:2.5.0 (evicted by: 2.6.1)
[info] +-com.google.protobuf:protobuf-java:2.6.1
[info] +-com.jgoodies:jgoodies-looks:2.7.0
[info] | +-com.jgoodies:jgoodies-common:1.8.1
[info] |
[info] +-com.typesafe.akka:akka-actor_2.11:2.3.13 [S]
View CollectionsPlayground.scala
// -Yno-predef
package collection
import scala.Predef.{???, println, implicitly}
trait Foreachable[T, U] {
def foreach(value: T, f: U Any): Unit
}
trait Indexable[T, U] {
def apply(value: T, index: Int): U
You can’t perform that action at this time.