Skip to content

Instantly share code, notes, and snippets.

View binarytemple's full-sized avatar

Bryan Hunt binarytemple

  • The mountains of mourne
View GitHub Profile
scala> import dispatch._
import dispatch._
scala> import Http._
import Http._
scala> import json.Js._
import json.Js._
scala> import twitter._
@binarytemple
binarytemple / ASDFFADS.scala
Created June 28, 2012 11:34
doesnt' seem to display anything, should be fractal
import java.awt.{ Color, Graphics2D, Dimension }
import swing.{ SimpleSwingApplication, Panel, Frame }
import util.Random
object ASDFFADS extends SimpleSwingApplication {
class FernFractalFrame(transformFunction: (Double, Double) => (Double, Double), val width: Int, val height: Int, val max: Int) extends Frame {
contents = new Panel {
preferredSize = new Dimension(width, height)
scala> val l = List("cat","dog","frog")
l: List[java.lang.String] = List(cat, dog, frog)
scala> Random.shuffle(l)
res8: List[java.lang.String] = List(frog, dog, cat)
scala> Random.shuffle(l).take(2)
res10: List[java.lang.String] = List(dog, frog)
@binarytemple
binarytemple / waitnofify.java
Created July 10, 2012 11:38
Java Wait Nofify Example
import java.util.ArrayList;
import java.util.List;
import static java.lang.String.format;
public class NotifyTest {
static final class NotifiableRunner extends Thread {
private final int id;
// The mutex upon which this thread will wait and respond to notify
@binarytemple
binarytemple / blah.scala
Created July 29, 2012 00:07
Specs test
"twitter json to Scala class mapper" should {
"parsing a tweet" in {
TwitterJsonMapper.tweetP(tweetS) match {
case Right(t: Tweet) => {
implicit def unOption[T](t: Option[T]): T = t.get
implicit def unEither[T](t: Either[T,Throwable]): T = t match {case Left(left) => left ;case Right(t) => throw t}
"test id" in {
true must_== (t.id.get == 228106060337135617l)
}
"test id_str" in {
options {
STATIC = false;
SUPPORT_CLASS_VISIBILITY_PUBLIC = true;
ERROR_REPORTING = false;
JAVA_UNICODE_ESCAPE = true;
UNICODE_INPUT = true;
NODE_USES_PARSER = false;
NODE_DEFAULT_VOID = true;
IGNORE_CASE = true;
VISITOR = true;
@binarytemple
binarytemple / multipart_email_example.py
Created January 15, 2013 17:38
Create a multipart email message, send to multiple recipients.
#!/usr/bin/env python2.7
import smtplib
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.mime.base import MIMEBase
from email import Encoders
msg = MIMEMultipart()
msg['Subject'] = "Greets from Bryan"
@binarytemple
binarytemple / some time
Last active December 11, 2015 17:59
time tracker
sed -n '/: [0-9]*:/{s_:0.*__;s_: __; p}' ~/.histfile > /tmp/graph.txt
cat <<END > ./plot.py
#!/usr/bin/python
#Python - Tidy and plot
from matplotlib.pylab import *
import matplotlib.pylab
@binarytemple
binarytemple / parentchild.scala
Last active December 17, 2015 16:08
Parent unaware of child failures
import akka.actor.Actor
import akka.actor._
import akka.actor.SupervisorStrategy._
import java.lang.UnsupportedOperationException
import java.util.concurrent.atomic.AtomicInteger
import java.util.concurrent.{TimeUnit, CountDownLatch}
import scala.concurrent.duration._
import scala.UnsupportedOperationException
@binarytemple
binarytemple / QueryTermParser.scala
Created June 12, 2013 15:40
Minimal Parboiled parser to parse Trapit query requests.
package com.zeebox.context.feedsingest.trapit
object QueryTermParser {
/**
* {{{
* A sample...
* "type:topic id:asddfasdsfafda Dessert"
* type A traps type: Bundle,Topic, or Source. String
* id GUID of the trap GUID
* }}}