Skip to content

Instantly share code, notes, and snippets.

Zohaib Sibte Hassan maxpert

Block or report user

Report or block maxpert

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
@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:
@maxpert
maxpert / gist:0b81f2474cb402279711f86001262fec
Created Aug 25, 2016 — forked from jedi4ever/gist:903751
Tuning stuff for Ubuntu hosts
View gist:0b81f2474cb402279711f86001262fec
# /etc/security/limits.conf
* soft nofile 999999
* hard nofile 999999
root soft nofile 999999
root hard nofile 999999
===========================================================
# /etc/sysctl.conf
# sysctl for maximum tuning
@maxpert
maxpert / restart_server.sh
Created Aug 20, 2016
A restart server shell script that daemonizes any
View restart_server.sh
#!/bin/bash
server_id=`cat server.pid`
if kill -9 $server_id > /dev/null 2>&1; then
echo "Server killed" >&2
fi
# start and banground server here
./server > /dev/null 2>&1 &
You can’t perform that action at this time.