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
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
// 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
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
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
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
# Communicate with an IRC channel from the shell | |
# | |
# Runs in background, writes messages to stdout in tty | |
# Depends on sic | |
TMPF=ircsession.tmp; CHAN='#testircfrombash'; ME=bot001; cat /dev/null > $TMPF; (tail -f $TMPF | sic -h irc.freenode.net -p 6667 -n $ME | while read MSG; do case "$MSG" in "$ME"*) echo ":j $CHAN" >> $TMPF;; "$CHAN"*) echo "$MSG";; esac; done;) & | |
# Then, to write to the channel: | |
echo "Hello all!" >> $TMPF | |
# or open a buffer to write many rows: |
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
CMD='last=JSON.load(ARGF.read)["data"]["last"]["display"]; puts "#{Time.now}: #{last}"'; watch "curl https://data.mtgox.com/api/2/BTCUSD/money/ticker 2>/dev/null | ruby -r json -e '$CMD'" |
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.util.concurrent.Executors | |
import concurrent.ExecutionContext | |
import concurrent.Future | |
import concurrent.Await | |
import scala.concurrent.duration._ | |
implicit val executionContext = ExecutionContext.fromExecutorService(Executors.newFixedThreadPool(2)) | |
Await.ready(Future { println("sdf") }, 3.seconds) |
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
/* | |
GNU GENERAL PUBLIC LICENSE | |
Version 3, 29 June 2007 | |
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> | |
Everyone is permitted to copy and distribute verbatim copies | |
of this license document, but changing it is not allowed. |