Skip to content

Instantly share code, notes, and snippets.

View utsengar's full-sized avatar
🚀
Hustling.

Utkarsh Sengar utsengar

🚀
Hustling.
View GitHub Profile
@utsengar
utsengar / singelton_classloader.java
Created June 14, 2011 04:13
fix singelton issues when using multiple classloaders
private static Class getClass(String classname) throws ClassNotFoundException {
ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
if(classLoader == null)
classLoader = Singleton.class.getClassLoader();
return (classLoader.loadClass(classname));
}
}
//Source: http://snehaprashant.blogspot.com/2009/01/singleton-pattern-in-java.html
/** The preceding method tries to associate the classloader with the current thread; if that
@utsengar
utsengar / map_reduce.py
Created June 6, 2011 08:31
map/reduce - Python
## {{{ http://code.activestate.com/recipes/577676/ (r9)
from collections import namedtuple
from math import fsum
def map_reduce(data, mapper, reducer=None):
'''Simple map/reduce for data analysis.
Each data element is passed to a *mapper* function.
The mapper returns key/value pairs
or None for data elements to be skipped.
@utsengar
utsengar / bootstrap.sh
Created June 2, 2011 19:00 — forked from anonymous/bootstrap.sh
Django on Heroku with Postgres, Celery and Sentry
virtualenv --no-site-packages .
source bin/activate
bin/pip install Django psycopg2 django-sentry
bin/pip freeze > requirements.txt
bin/django-admin.py startproject mysite
cat >.gitignore <<EOF
bin/
include/
lib/
EOF
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
function! NERDTreeQuit()
redir => buffersoutput
silent buffers
redir END
" 1BufNo 2Mods. 3File 4LineNo
let pattern = '^\s*\(\d\+\)\(.....\) "\(.*\)"\s\+line \(\d\+\)$'
let windowfound = 0
for bline in split(buffersoutput, "\n")
let m = matchlist(bline, pattern)
class Main{public static void main(String...args){\u0066or(int
\u0020$:"vÌÈÊ\"¤¾Àʲ¬Æ\"v¤Î¤\"²¤¨¸¬Æ".to\u0043h\u0061rArray()
)System./*goto/*$/%\u0126//^\u002A\u002Fout.print((char)(($>>
+(~'"'&'#'))+('<'>>('\\'/'.')/\u002Array.const(~1)\*\u002F)));}}
<div id="lga">
<style>
body{overflow:hidden}#hplogo{position:relative;width:0;margin:0 auto;right:190px;height:160px}.particle{position:absolute;z-index:-1}.circle{-moz-border-radius:160px;-webkit-border-radius:160px;-khtml-border-radius:160px;border-radius:160px}#cpf,#sbl,#fctr{background:transparent}
</style>
<noscript>
&lt;style&gt;#hplogo{right:0;width:auto;background:url(/intl/en_ALL/images/srpr/logo1w.png) no-repeat center}&lt;/style&gt;
</noscript>
<div id="hplogo">
<div class="particle circle" style="background-color: rgb(237, 157, 51); height: 18.337px; width: 18.337px; left: 200.733px; top: 77.5385px;">
</div>