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
View DumpIndexWriter.java
package mxp;
import java.io.IOException;
import org.apache.lucene.analysis.Analyzer;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.apache.lucene.document.NumericField;
import org.apache.lucene.index.CorruptIndexException;
@maxpert
maxpert / benchmarks-dump.txt
Created Mar 27, 2013
Go code to benchmark memcached binary and ASCII protocol.
View benchmarks-dump.txt
=========================
Testing with 100,000 gets
=========================
ASCII test...
ASCII 6.560225s
Binary test...
Binary 5.288102s
@maxpert
maxpert / nosqlite.py
Last active May 18, 2018
A really simple Document store built on top of SQLite3 using Python
View nosqlite.py
'''
Copyright (c) 2013 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 SOFTWARE OR THE
View Readme.md

Javascript #router. Features:

  • Just 70 lines of code.
  • Router scope can be bound to any object (default window); just change first parameter
  • Triggers custom DOM (Level 2) events on window.document.
  • IE 9+, FF, and Webkit based browsers [Tested only in Chrome and FF].
@maxpert
maxpert / decay_ranking.py
Created Jun 15, 2014
Decayed ranking basic implementation
View decay_ranking.py
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 / .htaccess
Last active Oct 29, 2017
PHP Long shadow icon generator.
View .htaccess
# for neater URLS like /{text}/{size}/{bg}
RewriteEngine on
RewriteRule ^img/([^/]+)/(\d+)/([a-fA-F0-9]{6})$ i/index.php?text=$1&size=$2&bg=$3 [NC,QSA]
RewriteRule ^img/([^/]+)/(\d+)$ i/index.php?text=$1&size=$2 [NC,QSA]
RewriteRule ^img/([^/]+)$ i/index.php?text=$1 [NC,QSA]
RewriteRule ^img/([^/]+)/.+$ i/index.php?text=$1 [NC,QSA]
@maxpert
maxpert / hash_test.go
Created Mar 16, 2015
JumpConsistentHash
View hash_test.go
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)
View Markup Sample.md

An exhibit of Markdown

This note demonstrates some of what Markdown Syntax is capable of doing.

Note: Feel free to play with this page. Unlike regular notes, this doesn't automatically save itself.

Basic formatting

Paragraphs can be written like so. A paragraph is the basic block of Markdown. A paragraph is what text will turn into when there is no reason it should become anything else.

Paragraphs must be separated by a blank line. Basic formatting of italics and bold is supported. This can be nested like so.

@maxpert
maxpert / Readme.md
Last active Dec 11, 2015
[Portable Class Library] WeakLambda implementation (can be used to make replacement of WeakEventManager in PCL environments).
View Readme.md

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 / LLRBTree.cs
Last active Feb 22, 2016
LLRBTree implementation in C#
View LLRBTree.cs
/// 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;
You can’t perform that action at this time.