Skip to content

Instantly share code, notes, and snippets.

@sheki
sheki / riakTest.java
Created February 24, 2011 17:15
A sample test to test Riak.
package ZZZ.platform.kv.riak;
import com.basho.riak.client.RiakClient;
import com.basho.riak.client.request.RequestMeta;
import com.basho.riak.client.response.FetchResponse;
import ZZZ.platform.config.ZZZConfig;
import ZZZ.platform.logging.ZZZLogger;
@sheki
sheki / InitServlet.java
Created March 15, 2011 06:57
A servlet which loads on Startup of a tomcat and initializes a thrift server.
package xyz.ping.server.impl;
import java.util.concurrent.TimeUnit;
import javax.servlet.http.HttpServlet;
import org.apache.thrift.protocol.TBinaryProtocol;
import org.apache.thrift.server.TThreadPoolServer;
import org.apache.thrift.server.TThreadPoolServer.Args;
import org.apache.thrift.transport.TServerSocket;
@sheki
sheki / Tomcat Thread Dump
Created March 15, 2011 18:21
Tomcat Thread dump buy kill -3. Caused by non starting thrift server
Full thread dump Java HotSpot(TM) 64-Bit Server VM (19.1-b02-334 mixed mode):
"TP-Monitor" daemon prio=5 tid=101c58800 nid=0x10b26e000 in Object.wait() [10b26d000]
java.lang.Thread.State: TIMED_WAITING (on object monitor)
at java.lang.Object.wait(Native Method)
- waiting on <7f3739e58> (a org.apache.tomcat.util.threads.ThreadPool$MonitorRunnable)
at org.apache.tomcat.util.threads.ThreadPool$MonitorRunnable.run(ThreadPool.java:565)
- locked <7f3739e58> (a org.apache.tomcat.util.threads.ThreadPool$MonitorRunnable)
at java.lang.Thread.run(Thread.java:680)
@sheki
sheki / storeCredit.scala
Created April 8, 2011 15:59
Attempted solution to goo.gl/NyPoz [Google code jam problem] in Scala.
import scala.util.Sorting.quickSort
class StoreItem(val price: Int, val index: Int) extends Ordered[StoreItem]
{
override def compare (that : StoreItem ) : Int = {
if (this.price equals that.price)
return this.index-that.index
else
this.price -that.price
@sheki
sheki / exception_received
Created April 9, 2011 17:17
Scala code to solve. http://goo.gl/B2tS9 Google code jam
Arrays received
1
3
-5
-2
4
1
scala.MatchError: ArraySeq(-5, 1, 3)
at Main$$anon$1.scalarProduct$1(minscalarProduct.scala:9)
at Main$$anon$1.Main$$anon$$minScalarProduct(minscalarProduct.scala:14)
@sheki
sheki / LinkedList.scala
Created April 14, 2011 15:00
Attempt at a linklist implementation in scala
case class Node(val data : Int, val next : Option[Node])
{
override def toString(): String = "node "+data
}
def printLinkedList ( node : Option[Node] ) : String ={
node match {
case None =>
case Node(data, next) => data+" "+printLinkedList(next)
}
}
@sheki
sheki / linux_box.md
Created June 9, 2011 04:03
jedis_benchmark

**Data size :500 ##Threads : 1 Time Test Ran for (ms) : 11213
Average : 0
50 % <=0
90 % <=0
95 % <=0
99 % <=0
99.9 % <=0
100 % <=52

@sheki
sheki / fkirc.py
Created July 9, 2011 17:59
A sample IRC file.
from twisted.words.protocols import irc
from twisted.internet import protocol
import sys
from twisted.internet import reactor , ssl
class MomBot(irc.IRCClient):
def _get_nickname(self):
return self.factory.nickname
nickname = property(_get_nickname)
@sheki
sheki / error.log
Created July 19, 2011 08:04
rabbitmq_error
{error_logger,{{2011,7,19},{13,28,50}},"Protocol: ~p: register/listen error: ~p~n",["inet_tcp",eaddrinuse]}
{error_logger,{{2011,7,19},{13,28,50}},crash_report,[[{initial_call,{net_kernel,init,['Argument__1']}},{pid,<0.20.0>},{registered_name,[]},{error_info,{exit,{error,badarg},[{gen_server,init_it,6},{proc_lib,init_p_do_apply,3}]}},{ancestors,[net_sup,kernel_sup,<0.9.0>]},{messages,[]},{links,[<0.17.0>]},{dictionary,[{longnames,false}]},{trap_exit,true},{status,running},{heap_size,610},{stack_size,24},{reductions,380}],[]]}
{error_logger,{{2011,7,19},{13,28,50}},supervisor_report,[{supervisor,{local,net_sup}},{errorContext,start_error},{reason,{'EXIT',nodistribution}},{offender,[{pid,undefined},{name,net_kernel},{mfargs,{net_kernel,start_link,[[rabbitmqctl31811,shortnames]]}},{restart_type,permanent},{shutdown,2000},{child_type,worker}]}]}
{error_logger,{{2011,7,19},{13,28,50}},supervisor_report,[{supervisor,{local,kernel_sup}},{errorContext,start_error},{reason,shutdown},{offender,[{pid,undefined},{name,n
@sheki
sheki / model.py
Created July 22, 2011 07:45
Example model
from sqlalchemy import Table, Column, Integer, String, ForeignKey
from sqlalchemy.orm import mapper
from database import metadata, db_session
class Team( object ):
query = db_session.query_property()
def __init__(self, name=None):
self.name = name