Skip to content

Instantly share code, notes, and snippets.

View maxpert's full-sized avatar

Zohaib Sibte Hassan maxpert

View GitHub Profile
@maxpert
maxpert / decay_ranking.py
Created June 15, 2014 17:53
Decayed ranking basic implementation
import math
import operator
class DecayScore(object):
"""
Class for calculating basic decayable score over keys (items) and there score values.
It's not thread safe and not doesn't store anykind of timestamps against items stored.
The caller is responsible of keeping track of time.
"""
@maxpert
maxpert / hash_test.go
Created March 16, 2015 02:18
JumpConsistentHash
package main
import "fmt"
type hash_function func (uint64, int32) int32
func main() {
for j := 1; j < 32; j++ {
simulate_rebalance("JumpConsistentHash", 32, int32(32 + j), JumpConsistentHash)
simulate_rebalance("ModConsistentHash", 32, int32(32 + j), ModConsistentHash)
@maxpert
maxpert / cookie.js
Created June 2, 2011 06:56
Cookie Wrapper
@maxpert
maxpert / autoscroll.js
Created October 15, 2011 13:51
Minimal jQuery Autoscroll to top
(function(jq) {
jq.autoScroll = function(ops) {
ops = ops || {};
ops.styleClass = ops.styleClass || 'scroll-to-top-button';
var t = jq('<div class="'+ops.styleClass+'"></div>'),
d = jq(ops.target || document);
jq(ops.container || 'body').append(t);
t.css({
opacity: 0,
@maxpert
maxpert / HDD info
Created June 10, 2012 19:32
TokyoCabinet + LZ4 speedups
/dev/sda:
ATA device, with non-removable media
Model Number: ST3250312AS
Serial Number: Z2A1KYYX
Firmware Revision: JC45
Transport: Serial
Standards:
Used: unknown (minor revision code 0x0029)
Supported: 8 7 6 5
@maxpert
maxpert / .vimrc
Created June 30, 2012 16:27
Vim configuration
set nocp
set bs=indent,eol,start
syntax on
set gcr=n:blinkon0
set sw=2 sts=2 et
set number ai
@maxpert
maxpert / entitiy_example.json
Created September 27, 2012 23:55
PostgreSQL vs MySQL FriendFeed casestudy
{
"id": "71f0c4d2291844cca2df6f486e96e37c",
"user_id": "f48b0440ca0c4f66991c4d5f6a078eaf",
"feed_id": "f48b0440ca0c4f66991c4d5f6a078eaf",
"title": "We just launched a new backend system for FriendFeed!",
"link": "http://friendfeed.com/e/71f0c4d2-2918-44cc-a2df-6f486e96e37c",
"published": 1235697046,
"updated": 1235697046,
}
@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

@maxpert
maxpert / benchmarks-dump.txt
Created March 27, 2013 21:04
Go code to benchmark memcached binary and ASCII protocol.
=========================
Testing with 100,000 gets
=========================
ASCII test...
ASCII 6.560225s
Binary test...
Binary 5.288102s
@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;