Skip to content

Instantly share code, notes, and snippets.

@inexplicable
inexplicable / full-calendar.html
Created February 6, 2017 23:33
use of full calendar jquery plugin
<!DOCTYPE html>
<html>
<head>
<title>My Calendar</title>
<link rel="stylesheet" href="bower_components/fullcalendar/dist/fullcalendar.css">
</head>
<body>
@inexplicable
inexplicable / Global.scala
Created November 13, 2014 23:41
play scala filter using rediscala async
/**
* Created by huzhou on 11/13/14.
*/
import play.api.mvc._
import filters.TokenFilter
object Global extends WithFilters(TokenFilter) {
}
@inexplicable
inexplicable / cassandra-throttle.scala
Created October 21, 2014 23:17
cassandra-throttle.scala
case object TakeAction
sealed trait ChannelAction{
def path:String //path is the primary key
}
case class SaveChannel(channelEntity:ChannelEntity, onComplete:(Boolean => Unit)) extends ChannelAction {
def path = channelEntity.path
}
@inexplicable
inexplicable / DCAwareness.scala
Created May 7, 2014 22:41
data center aware rebalance
package com.ebay.squbs.pubsub.cube
import akka.actor._
import akka.routing._
import scala.annotation.tailrec
import scala.collection.mutable
import scala.collection.immutable
import java.net._
import org.squbs.cluster.RebalanceLogic
import akka.util.ByteString
@inexplicable
inexplicable / ZkCluster.scala
Last active August 29, 2015 13:58
zookeeper based akka cluster management
package org.squbs.cluster
import java.io.File
import java.nio.ByteBuffer
import com.google.common.base.Charsets
import java.net.{NetworkInterface, URLDecoder, URLEncoder, InetAddress}
import org.apache.zookeeper.KeeperException.{NoNodeException, NodeExistsException}
import org.apache.zookeeper.{WatchedEvent, CreateMode}
import org.apache.zookeeper.Watcher.Event.EventType
import org.apache.curator.retry.ExponentialBackoffRetry
@inexplicable
inexplicable / akka-zk-cluster.scala
Created March 26, 2014 00:59
cluster backed by zk
package org.squbs.samples.pubsub.cluster
import akka.actor._
import com.twitter.zk.{ZNode, ZkClient, RetryPolicy}
import com.twitter.util._
import java.util.concurrent.TimeUnit
import scala.collection.mutable
import com.typesafe.config.ConfigFactory
import org.apache.zookeeper.CreateMode
import com.google.common.base.Charsets
@inexplicable
inexplicable / RouterActor.scala
Last active August 29, 2015 13:56
Akka & JeroMQ's router to enable messaging across Akka & External
package com.ebay
import akka.actor._
import org.zeromq.{ZMsg, ZContext, ZMQ}
import java.nio.charset.Charset
/**
* Created by huzhou on 2/4/14.
*/
package com.example
import akka.actor.{ActorRef, Actor}
import spray.routing._
import spray.http._
import MediaTypes._
// we don't implement our route structure directly in the service actor because
// we want to be able to test it independently, without having to spin up an actor
class MyServiceActor extends MyService {
@inexplicable
inexplicable / BitSet#nextSetBit.js
Created April 2, 2013 03:34
a unit test of #nextSetBit method using mocha & should.js
describe("#nextSetBit", function(){
var i = 0;
var bits = new BitSet();
it("should set 1 million times fast", function(done){
var begin = new Date().getTime();
for(var i = 0; i < 1000000; i += 1){
bits.set(i);
}