Skip to content

Instantly share code, notes, and snippets.

@rozza
rozza / JavadocFilter.java
Created March 7, 2019 15:43 — forked from benjchristensen/JavadocFilter.java
Doclet for filtering public classes from Javadoc
import java.lang.reflect.Array;
import java.lang.reflect.InvocationHandler;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;
import com.sun.javadoc.Doc;
import com.sun.javadoc.DocErrorReporter;
# First add a rule for all local traffic to port 80 to go into pipe 1
# 100 is the rule number which will be used for referencing the rule later
sudo ipfw add 100 pipe 1 ip from 127.0.0.1 to 127.0.0.1 dst-port http
# To display the rule use
# sudo ipfw show 100
# configure the settings of the pipe as you please
# 50kbit/s bandwidth
sudo ipfw pipe 1 config bw 50Kbit
# 200ms lag

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert $1 -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 $2

Results

import scala.tools.nsc.interpreter._
import scala.tools.nsc.Settings
//USAGE EXAMPLE: import break._;break[someClass]("MainObject" -> MainObject)
object break{
def echo(x: Any) = Console.println(x)
def break[T: Manifest](args: NamedParam*) = {
scala> class Bippy(xs: List[Int]) extends improving.TypesafeProxy(xs) { def isEmpty = true }
defined class Bippy
scala> val bippy = new Bippy(1 to 10 toList)
bippy: Bippy = List(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
scala> bippy.slice(3, 7)
[proxy] $line4.$read.$iw.$iw.bippy.slice(3, 7)
res1: List[Int] = List(4, 5, 6, 7)
import util.parsing.json.JSON
import io.Source
import scala.language.dynamics
object Example extends App{
val json = """{
"name" : "Adam Slodowy",
"active": "true",
"roles" : [ "teacher", "admin" ],
@rozza
rozza / Secured.scala
Created November 13, 2012 15:00 — forked from guillaumebort/Secured.scala
HTTP Basic Authorization for Play 2.0
def Secured[A](username: String, password: String)(action: Action[A]) = Action(action.parser) { request =>
request.headers.get("Authorization").flatMap { authorization =>
authorization.split(" ").drop(1).headOption.filter { encoded =>
new String(org.apache.commons.codec.binary.Base64.decodeBase64(encoded.getBytes)).split(":").toList match {
case u :: p :: Nil if u == username && password == p => true
case _ => false
}
}.map(_ => action(request))
}.getOrElse {
Unauthorized.withHeaders("WWW-Authenticate" -> """Basic realm="Secured"""")
@rozza
rozza / latency.md
Created May 31, 2012 21:16 — forked from marianposaceanu/latency.md
Latency numbers every programmer should know

CPU

  • L1 cache reference 0.5 ns
  • Branch mispredict 5 ns (on a bad CPU architecture you're pretty much screwed)
  • L2 cache reference 7 ns
  • Mutex lock/unlock 25 ns
  • Main memory reference 100 ns
  • Compress 1K bytes with Zippy 3,000 ns
  • Send 2K bytes over 1 Gbps network 20,000 ns
  • Read 1 MB sequentially from memory 250,000 ns