Skip to content

Instantly share code, notes, and snippets.

Alex Gleyzer agleyzer

Block or report user

Report or block agleyzer

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@agleyzer
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)
View ThreadedDemo.java
import java.io.File;
import java.util.logging.Logger;
public class ThreadedDemo {
private static Logger logger = Logger.getLogger("demo");
// "Inner class" represents a single thread that runs forever, looking for
// a certain file to appear, then "processes it," for demo
// purposes just renaming it to another name
static class Worker implements Runnable {
@agleyzer
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="http://d1snlc0orfrhj.cloudfront.net/presentations/12-mar-lockfreealgorithms.mp4" />
# </video>
# </div>
View gist:4003771
#!/usr/local/bin/perl
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
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) = {
@agleyzer
agleyzer / gist:6616242
Created Sep 18, 2013
a script to log http connections...
View gist:6616242
#!/bin/bash
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
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 java.net.{InetSocketAddress, SocketAddress}
import org.jboss.netty.handler.codec.http.HttpResponseStatus
import scala.util.Random
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 java.net.{InetAddress, InetSocketAddress, SocketAddress}
import java.security.Security
/**
@agleyzer
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 https://github.com/sbt/sbt/issues/714
stty columns 80
# avoid fancy colors that comint-mode won't support anyway
@agleyzer
agleyzer / akamai2graphite.py
Created Jan 29, 2014
Bulk loader for Akamai traffic reports CSV to Graphite
View akamai2graphite.py
#!/usr/bin/env python
import socket
from datetime import datetime
import csv
import sys
import pickle
import struct
import threading
import urllib2
You can’t perform that action at this time.