This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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) = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 java.net.InetAddress | |
import java.net.UnknownHostException | |
import java.net.{InetSocketAddress, SocketAddress} | |
import java.security.Security |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
from datetime import datetime | |
import csv | |
import sys | |
import pickle | |
import struct | |
import threading | |
import urllib2 |
OlderNewer