Skip to content

Instantly share code, notes, and snippets.

@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

Keybase proof

I hereby claim:

  • I am mushtaq on github.
  • I am mushtaq (https://keybase.io/mushtaq) on keybase.
  • I have a public key whose fingerprint is 1846 BF20 AF08 F926 A37A DA47 61B6 CC41 5592 2018

To claim this, I am signing this object:

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:
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