Skip to content

Instantly share code, notes, and snippets.

View maxpert's full-sized avatar

Zohaib Sibte Hassan maxpert

View GitHub Profile
@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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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)
@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