Skip to content

Instantly share code, notes, and snippets.

@rweeks
rweeks / gist:2363470
Created April 11, 2012 23:31
Example SBT build settings showing compiler options
name := "TCP Server Build Configuration"
version := "0.1.0"
scalaVersion := "2.9.1"
javacOptions ++= Seq("-Xlint:unchecked")
scalacOptions ++= Seq("-unchecked", "-deprecation")
@rweeks
rweeks / drag-enter.js
Created April 26, 2012 19:03
Using the pulse function
function drop_target_enter(e) {
var $dt = $(context.target_id)
$dt.addClass('dt-entered');
pulse($dt,
500,
'linear',
{opacity: 0.25},
{opacity: 1},
function() {
return $dt.hasClass('dt-entered') == false;
@rweeks
rweeks / gist:3708161
Created September 12, 2012 17:03
Tornado + redis-py pub/sub
class TileServer(tornado.web.Application):
def __init__(self, handlers=None, default_host="", transforms=None,
wsgi=False, **settings):
"""
In addition to invoking the superclass constructor, initializes the per-server redis client and per-server
redis pubsub handler.
"""
tornado.web.Application.__init__(self, handlers, default_host, transforms, wsgi, **settings)
self._rc = redis.StrictRedis(**(settings.get('redis_config', {}))) # redis client: one per application
self._rcps = self._rc.pubsub() # redis pubsub obj: one per application
@rweeks
rweeks / gist:3715400
Created September 13, 2012 16:09
StreamHandler
class StreamHandler(SessionAwareWSHandler):
@property
def feed_id(self):
return str(self.current_user.id) if self.current_user is not None else self.get_session_id()
def _set_earliest_tile(self, timestamp):
self.session.set_view_position(timestamp)
self.save_session()
@rweeks
rweeks / gist:4165962
Created November 29, 2012 00:56
min_queue.c
typedef struct node {
int v;
node *prev_min;
node *next;
} node;
typedef struct {
node *head;
node *tail;
} min_queue;
@rweeks
rweeks / mongoengine_test.py
Created February 18, 2013 20:40
Shows mongoengine tuple->list conversion
import unittest
from mongoengine.base import BaseField
from mongoengine.document import Document
from mongoengine.fields import ListField
from test import connect, disconnect
class EnumField(BaseField):
def __init__(self, **kwargs):
super(EnumField,self).__init__(**kwargs)
@rweeks
rweeks / LocalityGroupDeleter.scala
Created July 15, 2016 20:49
Delete all key-value pairs for a single locality group in Accumulo.
// this code is in the public domain
package com.newbrightidea.accumulo
import java.io.IOException
import java.util
import org.apache.accumulo.core.data.{ByteSequence, Key, Range, Value}
import org.apache.accumulo.core.iterators.{IteratorEnvironment, SortedKeyValueIterator, WrappingIterator}
import scala.collection.JavaConverters._
@rweeks
rweeks / VariantDereferencer.scala
Created October 11, 2016 02:10
Not-quite-pseudocode-not-quite-code showing how to go from a Transpose table to a Data table in Spark
package variantspark
import collection.JavaConverters._
import com.google.common.primitives.UnsignedBytes
import org.apache.accumulo.core.client.{IteratorSetting, ZooKeeperInstance}
import org.apache.accumulo.core.client.mapred.AccumuloInputFormat
import org.apache.accumulo.core.client.mapreduce.impl.DelegationTokenStub
import org.apache.accumulo.core.client.mapreduce.lib.impl.ConfiguratorBase._
import org.apache.accumulo.core.client.mapreduce.lib.impl.InputConfigurator
import org.apache.accumulo.core.data.{Key, Value, Range => ARange}