Skip to content

Instantly share code, notes, and snippets.

View maxpert's full-sized avatar

Zohaib Sibte Hassan maxpert

View GitHub Profile
@maxpert
maxpert / pubsub_test.go
Last active July 17, 2017 01:47
Golang Pub/Sub benchmarking
package rascore
import (
"testing"
"sync"
)
type info struct {
id int
}
@maxpert
maxpert / sample.js
Created February 17, 2017 08:49
ES6 Iterators
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)
@maxpert
maxpert / samples.yaml
Last active January 9, 2017 00:18
LUL
# 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 August 25, 2016 19:55 — forked from jedi4ever/gist:903751
Tuning stuff for Ubuntu hosts
# /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 August 20, 2016 00:50
A restart server shell script that daemonizes any
#!/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 &
@maxpert
maxpert / MarkdownSharp.cs
Last active April 15, 2016 01:46
Markdown to WinRT XAML converter
/*
* MarkdownSharp
* -------------
* a C# Markdown processor
*
* Markdown is a text-to-HTML conversion tool for web writers
* Copyright (c) 2004 John Gruber
* http://daringfireball.net/projects/markdown/
*
* Markdown.NET
@maxpert
maxpert / Crc64.cs
Created April 11, 2016 16:40
CRC64 implementation C#
public class Crc64
{
private static readonly ulong[] Table = {
0x0000000000000000, 0x7ad870c830358979,
0xf5b0e190606b12f2, 0x8f689158505e9b8b,
0xc038e5739841b68f, 0xbae095bba8743ff6,
0x358804e3f82aa47d, 0x4f50742bc81f2d04,
0xab28ecb46814fe75, 0xd1f09c7c5821770c,
0x5e980d24087fec87, 0x24407dec384a65fe,
0x6b1009c7f05548fa, 0x11c8790fc060c183,
@maxpert
maxpert / Stopwatch.kt
Created March 16, 2016 04:16
A really simple stopwatch for Kotlin
object Stopwatch {
inline fun elapse(callback: () -> Unit): Long {
var start = System.currentTimeMillis()
callback()
return System.currentTimeMillis() - start
}
inline fun elapseNano(callback: () -> Unit): Long {
var start = System.nanoTime()
@maxpert
maxpert / LLRBTree.cs
Last active February 22, 2016 03:07
LLRBTree implementation in C#
/// Copyright Zohaib Sibte Hassan under Apache 2.0 License http://www.apache.org/licenses/LICENSE-2.0
using System;
namespace sibte.so
{
public class LLRBTree<K, V> where K : IComparable
{
private const bool RED = true;
private const bool BLACK = false;
@maxpert
maxpert / Readme.md
Last active December 11, 2015 05:45
[Portable Class Library] WeakLambda implementation (can be used to make replacement of WeakEventManager in PCL environments).

Nuts and bolts for a Portable Class Library WeakEventManager

I spent my whole day (as a hobby) figuring out how can I implement equivalent of WeakEventManager. After a whole lot of digging around I concluded that I need a basic WeakLambda or WeakAction implementation. This implementation in-turn can be used by anything ranging from bulding WeakEvents, to WeakEventManager.

You are free to copy, rewrite, distribute code! May you never do bad and share the love!

Zohaib Sibte Hassan