Skip to content

Instantly share code, notes, and snippets.

@mushtaq
mushtaq / ExecutionContextMonitor.scala
Created June 2, 2017 08:02 — forked from atamborrino/ExecutionContextMonitor.scala
Monitor Scala's ExecutionContext / Akka Dispatcher lag (number of tasks in waiting queues)
import java.util.concurrent._
import akka.dispatch.{Dispatcher, ExecutorServiceDelegate}
import config.Config
import helpers.ScalaLogger
class ExecutionContextMonitor()(implicit metricsService: MetricsClient, config: Config) {
private val log = ScalaLogger.get(this.getClass)
private val scheduler = Executors.newSingleThreadScheduledExecutor()
@mushtaq
mushtaq / keybase.md
Created February 12, 2017 08:46
keybase.md

Keybase proof

I hereby claim:

  • I am mushtaq on github.
  • I am mushtaq (https://keybase.io/mushtaq) on keybase.
  • I have a public key ASB6mFQ-9WAtiCBizSV3nE4gSB2ZKFg53-d6No6Jwh7rYQo

To claim this, I am signing this object:

#!/bin/bash
file=$1
ffmpeg -ss 00:00:00 -t 02:00:00 -i $file -c copy "${file%.*}_part1.mp4"
ffmpeg -ss 02:00:00 -t 04:00:00 -i $file -c copy "${file%.*}_part2.mp4"
@mushtaq
mushtaq / AkkaHttpCorsSupport.scala
Created October 26, 2015 08:47 — forked from pcting/AkkaHttpCorsSupport.scala
Akka HTTP 1.0 CORS Support
import akka.http.scaladsl.model.HttpHeader
import akka.http.scaladsl.model.HttpMethods._
import akka.http.scaladsl.model.HttpResponse
import akka.http.scaladsl.model.headers.`Access-Control-Allow-Credentials`
import akka.http.scaladsl.model.headers.`Access-Control-Allow-Methods`
import akka.http.scaladsl.model.headers.`Access-Control-Allow-Origin`
import akka.http.scaladsl.model.headers.Origin
import akka.http.scaladsl.server.Directive0
import akka.http.scaladsl.server.Directives._
import akka.http.scaladsl.server.MethodRejection
@mushtaq
mushtaq / universal.scala
Last active February 12, 2016 01:14 — forked from paulp/universal.scala
// [info] Running p.Run
// List(Fish(Bob, Esq.,12), Kitty(Thor, Esq.,java.awt.Color[r=255,g=200,b=0]))
package misc
import java.awt.Color
trait Pet[A] {
def name(a: A): String
def renamed(a: A, newName: String): A
/** 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:
/*
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/
*/
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 {

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:

@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