Skip to content

Instantly share code, notes, and snippets.

class A
class A2 extends A
class B
trait M[X]
//
// Upper Type Bound
//
def upperTypeBound[AA <: A](x: AA): A = x
@mushtaq
mushtaq / gist:1330483
Created November 1, 2011 13:21
For patrick
trait Block[T] extends Function1[String, T]
object Block {
implicit def functionBlock[T](f: String => T): Block[T] = new Block[T] {
def apply(s: String): T = f(s)
}
implicit val unitBlock: Block[Unit] = new Block[Unit] {
def apply(s: String): Unit = {}
}
}
Originally:
https://gist.github.com/7565976a89d5da1511ce
Hi Donald (and Martin),
Thanks for pinging me; it's nice to know Typesafe is keeping tabs on this, and I
appreciate the tone. This is a Yegge-long response, but given that you and
Martin are the two people best-situated to do anything about this, I'd rather
err on the side of giving you too much to think about. I realize I'm being very
critical of something in which you've invested a great deal (both financially
@mushtaq
mushtaq / gist:1564624
Created January 5, 2012 10:26 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt
@mushtaq
mushtaq / iterm-commandline-editing-sublime-mode
Created July 22, 2012 09:50
iterm-commandline-editing-sublime-mode
#Add these mappings to .inputrc
"\e[1;9D": backward-word
"\e[1;9C": forward-word
"\e[D": beginning-of-line
"\e[C": end-of-line
"\e[1;3Z": backward-kill-word #configure iterm to send this signal for alt-delete
"\e[1;4Z": backward-kill-line #configure iterm to send this signal for cmd-delete
@mushtaq
mushtaq / gist:3596158
Created September 2, 2012 09:18 — forked from mandubian/gist:3377514
Play2 new plugin: File NonBlocking/Async API - Copying a file
"copy file" in {
var i = 0
val fileGenerator = Enumerator.fromCallback( () =>
if(i<1000){ i+=1; Future.successful(Some((new java.util.Date).getTime.toString + "\n")) } else Future(None)
)
val f = FileChannel("/tmp/testwrite.txt").delete.writing.create
val f2 = FileChannel("/tmp/testwrite2.txt").delete.writing.create
fileGenerator // generates data
@mushtaq
mushtaq / gist:3952521
Created October 25, 2012 13:24 — forked from etorreborre/gist:3949981
Finding bad jars in your maven repository
find . -name *.jar -exec bash -c "echo {} && jar tvf {} | head -n 1" \;
@mushtaq
mushtaq / FPStyleDIDemo.scala
Created November 18, 2012 13:06
Exploring DI options
package demos
import org.specs2.mutable._
class FPStyleDIDemo extends Specification {
class Db {
def name = "sony-db"
}
object Db {
@mushtaq
mushtaq / ScalaComponentsUseExtends.scala
Last active December 9, 2015 23:58
ScalaComponents
package demos
import org.specs2.mutable._
class ScalaComponentsUseExtends extends Specification {
trait DbComp {
class Db {
def name = "prod-db"
}
for {
product <- productRepo.getProduct(id)
metadata <- getMetadata(product.id)
} yield metadata
flow {
val product = productRepo.getProduct(id)()