Skip to content

Instantly share code, notes, and snippets.

agleyzer / global.sbt
Last active Aug 29, 2015
SBT global settings (~/.sbt/global.sbt)
View global.sbt
// should go in ~/.sbt/global.sbt
shellPrompt := { state =>
import sbt.Keys.{name, version}
import scala.Console.RESET
val YELLOW_I = "\033[0;93m"
val GREEN_I = "\033[0;92m"
val RED_I = "\033[0;91m"
val BLACK_I = "\033[0;90m"
val CYAN_I = "\033[0;96m"
val s = Project.extract(state)
agleyzer /
Created Jan 29, 2014
Bulk loader for Akamai traffic reports CSV to Graphite
#!/usr/bin/env python
import socket
from datetime import datetime
import csv
import sys
import pickle
import struct
import threading
import urllib2
agleyzer / gist:7758128
Created Dec 2, 2013
my ~/.sbtconfig, works w/ SBT 0.13 and ansi-term
View gist:7758128
SBT_OPTS="-XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=256m -Xmx512M -Xss2M"
# this allows sbt to be executed in Emacs terminal
if [[ -n $EMACS ]]; then
echo "Emacs detected, commencing hijacking sequence..."
# to avoid division by zero, with jline 1.0, see
stty columns 80
# avoid fancy colors that comint-mode won't support anyway
View DnsBackedName.scala
import com.twitter.conversions.time._
import com.twitter.finagle.{Addr, Name}
import com.twitter.finagle.util.DefaultTimer
import com.twitter.logging.Logger
import com.twitter.util.{Duration, Future, FuturePool, Timer, Updatable, Var}
import{InetAddress, InetSocketAddress, SocketAddress}
agleyzer / finagle_demo.scala
Created Oct 10, 2013
NYT Code Weekly Finagle Demo
View finagle_demo.scala
import com.twitter.conversions.time._
import com.twitter.finagle.Service
import com.twitter.finagle.builder.{ClientBuilder, Server, ServerBuilder}
import com.twitter.finagle.http.{Http, Request, Response, RichHttp}
import com.twitter.finagle.util.DefaultTimer
import com.twitter.finagle.util.DefaultTimer.{twitter => timer}
import com.twitter.util.{Await, Future, Stopwatch}
import{InetSocketAddress, SocketAddress}
import org.jboss.netty.handler.codec.http.HttpResponseStatus
import scala.util.Random
agleyzer / DnsCluster.scala
Created Oct 9, 2013
A Finagle Cluster that uses DNS, based on ZookeeperServerSetCluster.
View DnsCluster.scala
import com.twitter.concurrent.Spool
import com.twitter.finagle.builder.Cluster
import com.twitter.finagle.util.DefaultTimer
import com.twitter.logging.Logger
import com.twitter.util.FuturePool
import com.twitter.util.{Duration, Future, JavaTimer, Promise, Return, Time, Timer}
import{InetSocketAddress, SocketAddress}
agleyzer / gist:6616242
Created Sep 18, 2013
a script to log http connections...
View gist:6616242
ts=$(date +%Y%m%d-%H%M%S)
tcpdump -A -s 1492 -l \
'host blahblah and tcp port 80 and (((ip[2:2] - ((ip[0]&0xf)<<2)) - ((tcp[12]&0xf0)>>2)) != 0)' \
| grep HTTP -C 10 > httpdump-${ts}.log 2>&1 &
disown %1
agleyzer / TetrisShapes.scala
Created Mar 8, 2013
Calculates all possible Tetris-like shapes for a given number of squares.
View TetrisShapes.scala
// Calculates all possible Tetris-like shapes for a given number of
// squares.
object TetrisShapes extends App {
type Point = (Int, Int) // x, y
type Shape = Set[Point]
// returns a list of neighbors for a point
def neighbors(p: Point) = {
View gist:4003771
use CGI qw/:standard/ ;
use strict;
# demonstration how mod_perl may screw up your naive CGI code... Call
# this script passing different name parameter several times.
my $name = param('name') || "professor";
agleyzer / gist:3859749
Created Oct 9, 2012
Download infoq video
View gist:3859749
#!/usr/bin/env python
# Looking for MP4 videos in infoq content.
# <div style="width: 320px; height: 265px; float: left; margin-right: 10px;">
# <video poster="/styles/i/logo_scrubber.png" id="video" controls="controls" width="320" height="265">
# <source src="" />
# </video>
# </div>
You can’t perform that action at this time.