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 scala.language.implicitConversions | |
class Mult[A, B] { | |
def commute: Mult[B, A] = new Mult[B, A] | |
def associate[C, D](implicit ev: B =:= Mult[C, D]): Mult[Mult[A, C], D] = new Mult[Mult[A, C], D] | |
} | |
object Simplify { | |
implicit def commute[A, B, M <% Mult[A, B]](m: M): Mult[B, A] = m.commute | |
implicit def associate[A, B, C, M <% Mult[A, Mult[B, C]]](m: M): Mult[Mult[A, B], C] = m.associate |
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
object Welp { | |
def foobar(a: Int, b: Int, c:Int) { throw new IllegalArgumentException } | |
def main(args: Array[String]) { | |
List(3) map { | |
try { | |
foobar(1, 2, _) | |
} catch { | |
case e: Throwable => { // This set of braces is optional. Problem remains when removed. | |
println("won't be printed") |
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
package com.tapad.common.metrics | |
import java.net.Socket | |
import java.io._ | |
import com.tapad.common.log.Logging | |
import com.twitter.ostrich.stats._ | |
import java.util.TimerTask | |
object GraphiteReporter { | |
def apply(prefix: String, host: String, port: Int, reportInterval: Long) = { |
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
// this is the build file used to compile piday.scala | |
name := "piday" | |
scalaVersion := "2.10.3" | |
libraryDependencies += "org.spire-math" %% "spire" % "0.7.3" |
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/sh | |
function copy_if_changed { | |
local path_from="$2/$1" | |
local path_to="$3/$1" | |
local md5_from=$(md5 -q $path_from) | |
if [ -e $path_to ] | |
then |
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
sealed trait Foo | |
case class Bar(x: Int) extends Foo | |
case class Baz(name: String) extends Foo | |
object Foo { | |
def show(f: Foo) = | |
f match { | |
case Bar(x) => x.toString // Quux, a subtype of Bar in a different file, will be matched as a Bar | |
case Baz(name) => name | |
} |
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
<?php | |
/* | |
* This is a simple example of using PHP's OAuth extension to fetch a valid | |
* token for a given member. The process is a typical OAuth 1.0a flow, which | |
* includes requesting a member's authorization to act on her behalf and then | |
* fetching the actual token once authorized. This token can then be stored | |
* and used to make API calls on the member's behalf. For an example of making | |
* such a call once you have retriefed an authorized token, see: | |
* |
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 scala.language.higherKinds | |
trait Bifunctor[BF[_, _]] { | |
def bimap[A, B, C, D](bf: BF[A, C], fab: A => B, fcd: C => D): BF[B, D] | |
/* Mapping over one of the sides is convenient and can be implemented easily | |
in terms of `bimap`. */ | |
/** Map over the "first" side, transforming the type and potentially the value | |
(if the BF instance is of the "first" type, natrually.) */ |
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
object Fλip { | |
val tParams = (1 to 23).map { i => | |
(i + 'A' - 1).toChar | |
} | |
def getParams(arity: Int): IndexedSeq[Char] = | |
(0 to arity).map(tParams(_)) | |
def getTypeSig(seq: IndexedSeq[Char]) = | |
s"""(${seq.init.mkString(",")}) => ${seq.last}""" |
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
ubuntu@ip-10-74-149-134:~$ mkdir rust-buildbox | |
ubuntu@ip-10-74-149-134:~$ cd rust-buildbox/ | |
ubuntu@ip-10-74-149-134:~/rust-buildbox$ vim Dockerfile | |
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker build -t rust-buildbox . | |
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker images | |
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE | |
rust-buildbox latest be231641cce2 18 seconds ago 1.277 GB | |
ubuntu 14.04 c4ff7513909d 11 days ago 213 MB | |
ubuntu@ip-10-74-149-134:~/rust-buildbox$ docker run -t -i rust-buildbox /bin/bash | |
root@45ac8578f983:/# cd /home/rust/ |
OlderNewer