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
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 / 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" \;
package com.linkedin.playplugins.common.util
import Cache._
import play.api.Configuration
import java.util.concurrent.ConcurrentHashMap
import collection.JavaConverters._
/**
* A Scala wrapper for a Java's ConcurrentHashMap (CHM). Exposes the basic underlying methods of CHM and adds a
* getOrElseUpdate(key, value) method that lazily evaluates the value parameter only if the key is not already present
@mushtaq
mushtaq / 0_reuse_code.js
Created June 1, 2014 06:30
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
package scalax.collection
import scala.collection.mutable.ListBuffer
/** FoldTransformers and the views based on them are a Scala
* adaptation, and to some degree an extension, of Rich Hickey's
* transducers for Clojure. They show that the concepts can be
* implemented in a type-safe way, and that the implementation is
* quite beautiful.
*/
object FoldingViews {
/*
This example uses Scala. Please see the MLlib documentation for a Java example.
Try running this code in the Spark shell. It may produce different topics each time (since LDA includes some randomization), but it should give topics similar to those listed above.
This example is paired with a blog post on LDA in Spark: http://databricks.com/blog
Spark: http://spark.apache.org/
*/
/** This is in reference to @tploecat's blog http://tpolecat.github.io/2015/04/29/f-bounds.html
* where he compares F-bounded polymorphism and type classes for implementing "MyType".
*
* Curiously, the in my mind obvious solution is missing: Use abstract types.
*
* A lot of this material, including an argument against F-bounded for the use-case
* is discussed in:
*
* Kim B. Bruce, Martin Odersky, Philip Wadler: