Skip to content

Instantly share code, notes, and snippets.

View dln's full-sized avatar
🚀

Daniel Lundin dln

🚀
View GitHub Profile
@dln
dln / ttldict.py
Created August 14, 2010 11:32
Implementaion a dictionary with timed expiration of values.
import time
class TtlDict(dict):
"""A dict where values expire after a set time.
Expiration is done on access, or using `prune` (linear)"""
ttl = 5
def __init__(self, *args, **kwargs):
dict.__init__(self, *args, **kwargs)
@dln
dln / jmx.scala
Created May 3, 2011 09:45
Reading some JMX MBeans from a Scala script
#!/bin/sh
exec scala $0 "$@"
!#
import scala.collection.JavaConversions._
import java.lang.management.{ManagementFactory, MemoryMXBean}
import java.net.URI
import javax.management.JMX
import javax.management.remote.{JMXConnectorFactory, JMXServiceURL}
@biesnecker
biesnecker / ScalaJetty.scala
Created August 17, 2011 23:17
Main method
package com.biesnecker.scalajetty
import cc.spray._
import org.eclipse.jetty.server.Server
import org.eclipse.jetty.xml.XmlConfiguration
import org.eclipse.jetty.webapp.WebAppContext
import java.io.File
object ScalaJetty {
@ajsutton
ajsutton / BackgroundLogger.java
Created September 26, 2011 20:13
Disruptor Example of Background Logging
import com.lmax.disruptor.RingBuffer;
import com.lmax.disruptor.dsl.Disruptor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
public class BackgroundLogger
{
private static final int ENTRIES = 64;
@mccv
mccv / gist:1259343
Created October 3, 2011 15:14
OAuth with finagle streaming
import java.net._
import java.util.UUID
import com.twitter.conversions.time._
import com.twitter.finagle.builder.ClientBuilder
import com.twitter.util._
import java.nio.charset.Charset
import org.jboss.netty.buffer.{ChannelBuffers, ChannelBuffer}
import org.jboss.netty.handler.codec.http._
import com.twitter.finagle.stream.Stream
@lordkev
lordkev / ec2_enc.rb
Created October 13, 2011 20:43
Puppet EC2 Security Group ENC
#!/usr/bin/ruby
##
# Classifies a puppet node based on its EC2 security group.
# Requires the AWS gem.
# Also requires a node_groups.yml file which specifies security groups
# and the classes/params that should be applied, in the following
# format (additionally keyed by security group name).
# http://docs.puppetlabs.com/guides/external_nodes.html
#
@timcowlishaw
timcowlishaw / Trie.scala
Created November 14, 2011 10:06
A Trie (Prefix-tree) implementation in Scala
package uk.ac.ucl.cs.GI15.timNancyKawal {
class Trie[V](key: Option[Char]) {
def this() {
this(None);
}
import scala.collection.Seq
import scala.collection.immutable.TreeMap
import scala.collection.immutable.WrappedString
@dln
dln / inotify-cmake.sh
Created July 17, 2012 10:36
Continuous build on the cheap, using inotify, cmake and a terminal
#!/bin/bash
# Watch paths (given as arguments), automatically build when something changes.
# The script does a couple opinionated things to make my life easier:
#
# * Terminal scrollbuffer is reset before each iteration, simplifying scrolling.
# * I use a filter script to colorize gcc output (clang errors would be nicer).
# * Output is copied to a log file (/tmp/build.log).
# - I open this file in Sublime or vim, which reloads the file on change (each build).
#
# Usage:

Don't use MongoDB

I've kept quiet for awhile for various political reasons, but I now feel a kind of social responsibility to deter people from banking their business on MongoDB.

Our team did serious load on MongoDB on a large (10s of millions of users, high profile company) userbase, expecting, from early good experiences, that the long-term scalability benefits touted by 10gen

@phobos182
phobos182 / kafka_consumer.py
Created October 22, 2012 15:07
Kafka Graphite Consumer
#!/usr/bin/env python
from optparse import OptionParser
from brod.zk import *
import pickle
import struct
import socket
import sys
import time