Skip to content

Instantly share code, notes, and snippets.

View maxpert's full-sized avatar

Zohaib Sibte Hassan maxpert

View GitHub Profile
@maxpert
maxpert / .dockerignore
Last active January 22, 2024 14:01
Marmot + PocketBase + Fly.io
/.git
@maxpert
maxpert / README.md
Created December 7, 2022 03:33
Redis Toolbelt

Set of Deno scripts with some powerful toolbelt scripts for Redis

MIT License

Copyright (c) 2022 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

@maxpert
maxpert / License.md
Last active October 16, 2022 22:32
Marmot Scripts

MIT License

Copyright (c) 2022 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:

@maxpert
maxpert / README.md
Last active September 17, 2021 19:59
JDK 17 benchmarks

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 October 5, 2020 19:13
Redis PING Implementation for JGroups
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 August 1, 2018 05:29
Kotlin Coroutine Debouncer
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 July 30, 2018 08:40
51873 Blockchain

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 February 15, 2018 07:02
Redis compressed values benchmark
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 December 21, 2017 12:21
Minimal BrainF*ck implementation in 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 July 26, 2017 15:28
Python pipe syntactic sugar
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)