Skip to content

Instantly share code, notes, and snippets.

View maxpert's full-sized avatar

Zohaib Sibte Hassan maxpert

View GitHub Profile
http://stackoverflow.com/questions/4073092/errno-9-using-the-multiprocessing-module-with-tornado-in-python
p = multiprocessing.Pool(4)
class QueryHandler(tornado.web.RequestHandler):
...
@tornado.web.asynchronous
def get(self):
...
p.apply_async(async_func, [sql_command, arg1, arg2, arg3, ],
callback_func)
@headius
headius / gist:1408381
Created November 30, 2011 07:54
JRuby Fiber perf compared to 1.9.3
# Ruby 1.9.3
ruby-1.9.3-p0 ~/projects/jruby $ ruby -v bench/bench_fiber_ring.rb 5 100 1000
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin10.8.0]
bench/bench_fiber_ring.rb:23: warning: mismatched indentations at 'end' with 'def' at 21
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.155022)
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.153985)
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.153822)
100 fibers / 1000 passes: 0.150000 0.000000 0.150000 ( 0.152370)
100 fibers / 1000 passes: 0.160000 0.000000 0.160000 ( 0.155857)
@maxpert
maxpert / Femto.js
Created May 24, 2011 17:16
Femto JS Templating
/**
The MIT License
Copyright (c) 2010 Zohaib Sibt-e-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
@plugnburn
plugnburn / README.md
Last active June 1, 2018 21:42
XT.js - DOM construction / templating library in 18 lines of JS, 323 bytes minified

XT.js

Let's close the ultra-small library cycle with some awesome array-based templating. 323 bytes minified.

How to obtain

Just download the minified version here or include it into your code:

@mwunsch
mwunsch / avatar.sh
Last active June 23, 2018 17:41
Random Avatar Generator
curl -s 'http://realbusinessmen.tumblr.com/api/read?type=photo&num=50' | ruby -r'rexml/document' -e 'puts REXML::Document.new(STDIN).elements["tumblr/posts"].to_a.shuffle.pop.map(&:text)'
#!/bin/bash
# file descriptor
# Change 400000 to increase or decrease number of file descriptor
echo "* soft nofile 400000" >> /etc/security/limits.conf
echo "* hard nofile 400000" >> /etc/security/limits.conf
# Changing kernal parameters (modify value if required)
# coding=UTF-8
from __future__ import division
import re
# This is a naive text summarization algorithm
# Created by Shlomi Babluki
# April, 2013
class SummaryTool(object):
@manishtpatel
manishtpatel / main.go
Last active October 18, 2023 03:12
GoLang Encrypt string to base64 and vice versa using AES encryption.
package main
import (
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"encoding/base64"
"fmt"
"io"
)
@jlong
jlong / uri.js
Created April 20, 2012 13:29
URI Parsing with Javascript
var parser = document.createElement('a');
parser.href = "http://example.com:3000/pathname/?search=test#hash";
parser.protocol; // => "http:"
parser.hostname; // => "example.com"
parser.port; // => "3000"
parser.pathname; // => "/pathname/"
parser.search; // => "?search=test"
parser.hash; // => "#hash"
parser.host; // => "example.com:3000"
@frsyuki
frsyuki / my_thoughts_on_msgpack.md
Created June 11, 2012 02:36
My thoughts on MessagePack

My thoughts on MessagePack

Hi. My name is Sadayuki "Sada" Furuhashi. I am the author of the MessagePack serialization format as well as its implementation in C/C++/Ruby.

Recently, MessagePack made it to the front page of Hacker News with this blog entry by Olaf, the creator of the Facebook game ZeroPilot. In the comment thread, there were several criticisms for the blog post as well as MessagePack itself, and I thought this was a good opportunity for me to address the questions and share my thoughts.

My high-level response to the comments

To the best of my understanding, roughly speaking, the criticisms fell into the following two categories.