Skip to content

Instantly share code, notes, and snippets.

View maxpert's full-sized avatar

Zohaib Sibte Hassan maxpert

View GitHub Profile

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 / 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 / .htaccess
Last active October 29, 2017 06:40
PHP Long shadow icon generator.
# 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 / 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.
"""

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 / nosqlite.py
Last active May 18, 2018 22:21
A really simple Document store built on top of SQLite3 using Python
'''
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
@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 / DumpIndexWriter.java
Created October 8, 2012 16:59
Lucene redis example
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 / 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 / piratebay_index.py
Created September 25, 2012 13:14
Quick and dirty Whoosh Redis storage
"""
Copyright (c) 2012 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