This file contains hidden or 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
| package object util { | |
| object Times { | |
| trait TimesDoer[-Value, Result] { | |
| def times(n: Int)(f: => Value): Result | |
| } | |
| implicit object TimesUnit extends TimesDoer[Unit, Unit] { | |
| def times(n: Int)(f: => Unit): Unit = for (_ <- 0 until n) f | |
| } |
This file contains hidden or 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._ | |
| @SerialVersionUID(15L) | |
| class Animal(name: String, age: Int) extends Serializable { | |
| override def toString = s"Animal($name, $age)" | |
| } | |
| case class Person(name: String) | |
| // or fork := true in sbt |
This file contains hidden or 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 annotation.tailrec | |
| import scala.math.Ordering.Implicits._ | |
| object MergeSort { | |
| def apply[T : Numeric](xs: Seq[T]): Seq[T] = { | |
| val n = xs.length / 2 | |
| if (n == 0) | |
| xs | |
| else { |
This file contains hidden or 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
| // HList implementation | |
| sealed trait HList | |
| final case class HCons[H, T <: HList](head: H, tail: T) extends HList { | |
| def ::[T](v : T) = HCons(v,this) | |
| override def toString = head + " :: " + tail | |
| } | |
| final class HNil extends HList { |
This file contains hidden or 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
| git diff current_release..master --name-only -- . | grep migration | xargs -n1 sed '/^\s\+models = /,$d' | view - -c 'set ft=python' |
This file contains hidden or 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 | |
| # | |
| # Author: Eric Gebhart | |
| # | |
| # Purpose: To be called by mutt as indicated by .mailcap to handle mail attachments. | |
| # | |
| # Function: Copy the given file to a temporary directory so mutt | |
| # Won't delete it before it is read by the application. | |
| # | |
| # Along the way, discern the file type or use the type |
This file contains hidden or 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
| SECRET_BREAKOUT_RETURN_CODE=119 | |
| while scala; [ $? != $SECRET_BREAKOUT_RETURN_CODE ] ; do continue; done |
This file contains hidden or 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 time.sleep | |
| import zmq | |
| context = zmq.Context() | |
| socket = context.socket(zmq.PUB) | |
| socket.bind('tcp://127.0.0.1:2000') | |
| # Allow clients to connect before sending data | |
| sleep(10) | |
| socket.send_pyobj({1:[1,2,3]}) |
This file contains hidden or 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
| exec 4<>/dev/tcp/gopher.meulie.net/70 | |
| echo "" >&4 | |
| cat <&4 |
This file contains hidden or 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
| class selfdestructing_tempdir(object): | |
| def __enter__(self): | |
| import tempfile | |
| self._tempdir = tempfile.mkdtemp() | |
| return self._tempdir | |
| def __exit__(self, type, value, traceback): | |
| import shutil | |
| shutil.rmtree(self._tempdir) |