Skip to content

Instantly share code, notes, and snippets.

Avatar

Zohaib Sibte Hassan maxpert

View GitHub Profile
@maxpert
maxpert / README.md
Last active Sep 17, 2021
JDK 17 benchmarks
View README.md

Here are some benchmarks of JDK 17 GCs. I wanted to compare a basic service running on Vert.x fetching and stream (HTTP chuncked transfer) 500 rows, serializing them to JSON (almost 30KB when serialized), send them over wire (buffered). Here are tech specs of this benchmarks:

  • All processes including Vegeta, Postgres, and Java were running on same machine
  • Host machine is a 2015 Macbook Pro (2.2 GHz Quadcore Intel Core i7), with 16 GB 1600 MHZ DDR3 RAM.
  • Each benchmark was warmed up by first running atleast 3 1000 req/s stress tests before the readings posted in these benchmarks.
  • RSS of each process was noted towards the end of benchmarks.
@maxpert
maxpert / REDIS_PING.kt
Created Oct 5, 2020
Redis PING Implementation for JGroups
View REDIS_PING.kt
package luna.lib
import io.lettuce.core.RedisClient
import io.lettuce.core.RedisException
import io.lettuce.core.cluster.RedisClusterClient
import io.lettuce.core.cluster.api.sync.RedisClusterCommands
import org.jgroups.Address
import org.jgroups.annotations.MBean
import org.jgroups.annotations.Property
import org.jgroups.conf.ClassConfigurator
@maxpert
maxpert / CoroutineDebouncer.kt
Created Aug 1, 2018
Kotlin Coroutine Debouncer
View CoroutineDebouncer.kt
class CoroutineDebouncer<K, V> constructor(
private val pendingBoard: ConcurrentMap<K, Deferred<V?>>
) {
/**
* Debounce given a `task` based upon given `id`. This prevents jobs with same IDs run in parallel.
* For subsequent callers get Deferred<V> of first (winning) coroutine.
* Once Deferred<V> completes it is remove from the board.
*
* @param id for uniquely identifying a task
* @param context under which given coroutine will be executed
@maxpert
maxpert / README.md
Last active Jul 30, 2018
51873 Blockchain
View README.md

A toy blockchain implementation made for fun.

Implements:

  • Basic in-memory blockchain
  • Basic Proof of work
  • Methods to serialize/deserialize complete chain

Again none of this is supposed to be production ready.

@maxpert
maxpert / Results.txt
Created Feb 15, 2018
Redis compressed values benchmark
View Results.txt
Slow network time in seconds (100Mbps):
LZ4/Write takes: 0.2853062963485718
LZ4/Read takes: 0.3265376162528992
QLZ/Write takes: 0.31065379858016967
QLZ/Read takes: 0.4505005311965942
ZSTD/Write takes: 0.1596823501586914
ZSTD/Read takes: 0.2516604351997376
ZLIB/Write takes: 0.3231374764442444
ZLIB/Read takes: 0.2478048324584961
UC/Write takes: 0.7657859945297241
@maxpert
maxpert / Brainfuck.js
Last active Dec 21, 2017
Minimal BrainF*ck implementation in JS
View Brainfuck.js
/**
* Copyright 2017 Zohaib Sibte Hassan
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWAR
@maxpert
maxpert / pipes.py
Last active Jul 26, 2017
Python pipe syntactic sugar
View pipes.py
import inspect
class PipeFunction:
def __init__(self, func, *args, **kwargs):
self._func = func
self._args = args
self._kwargs = kwargs
def __call__(self, *args, **kwargs):
return self._append_params(*args, **kwargs)
@maxpert
maxpert / pubsub_test.go
Last active Jul 17, 2017
Golang Pub/Sub benchmarking
View pubsub_test.go
package rascore
import (
"testing"
"sync"
)
type info struct {
id int
}
@maxpert
maxpert / sample.js
Created Feb 17, 2017
ES6 Iterators
View sample.js
function $range(...args) {
let [start, stop, step] = args
if (stop === undefined) {
stop = start
start = 0
}
let direction = start < stop ? 1 : -1
let i = start
step = step || (1 * direction)
View samples.yaml
# Everything starting with a # is a comment
################################## 1-1-simple-example.rive
on: Hello bot
say: Hello human
################################## 1-2-replies.rive
# By default all statements live under start, this can be explicitly specified
start:
on: hello bot
say: