Skip to content

Instantly share code, notes, and snippets.

View gideondk's full-sized avatar

Gideon de Kok gideondk

View GitHub Profile
index 6333cb5..c6465ab 100644
--- a/lib/cassandra_object/persistence.rb
+++ b/lib/cassandra_object/persistence.rb
@@ -63,7 +63,7 @@ module CassandraObject
end
def all(keyrange = ''..'', options = {})
- connection.get_range(column_family, :start => keyrange.first, :finish => keyrange.last, :count=>(options[:limit] || 100)).map {|key| get(key) }
+ connection.get_range(column_family, :start => keyrange.first, :finish => keyrange.last, :count=>(options[:limit] || 100)).map {|column| get(column.key) }
end
require 'rubygems'
require 'em-websocket'
require 'em-mongo'
require 'json'
require 'geokit'
require 'digest/md5'
chat_messages = []
@@session_time_out = 60 * 10
<!doctype html>
<html>
<head>
<title>socket.io client test</title>
<style>
#chat { height: 300px; overflow: auto; width: 800px; border: 1px solid #eee; font: 13px Helvetica, Arial; }
#chat p { padding: 8px; margin: 0; }
#chat p:nth-child(odd) { background: #F6F6F6; }
#form { width: 782px; background: #333; padding: 5px 10px; display: none; }
#form input[type=text] { width: 700px; padding: 5px; background: #fff; border: 1px solid #fff; }
@gideondk
gideondk / gist:1475806
Created December 14, 2011 08:59
XMLHttpRequest Play 2.0 Test
<html>
<head>
<title>Drag and drop Play2.0 Test</title>
<script type='text/javascript' src='https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js' charset='utf-8'></script>
<script type='text/javascript'>
var dnd = {
ready : function()
{
$('div#uploadTarget')
.bind(
@gideondk
gideondk / gist:3090339
Created July 11, 2012 13:16
Redis write through cache for Scaliak (using Sedis)
abstract class WriteThroughRedisDomainHelper[T <: DomainObject](override val clientPool: ScaliakPbClientPool, val redisPool: Pool)(implicit mo: Manifest[T]) extends DomainObjectHelper[T](clientPool) {
override def fetch(k: String) = {
redisPool.withClient { _.get(k) }.map { parse(_) }.successNel.pure[IO].except { _.failNel.pure[IO] }.flatMap { x ⇒
~x.toOption match {
case Some(o) if (o != null) ⇒ x.pure[IO]
case None ⇒ super.fetch(k)
}
}
}
MapReducePhasePipe(mapValuesToJson(false) |- sort(field, sortDESC))
object Photo extends DomainObjectWrapper[Photo](classOf[Photo])
val client = Scaliak.pbClient("127.0.0.1", 8087, 8098)
val clientPool = new ScaliakPbClientPool("127.0.0.1", 8087, 8098)
val clientPool = new ScaliakPbClientPool("127.0.0.1", 8087, 8098)