Skip to content

Instantly share code, notes, and snippets.


vasani83 cvasani

View GitHub Profile
cvasani / Main.scala
Created May 25, 2019 — forked from jkpl/Main.scala
Ways to pattern match generic types in Scala
View Main.scala
object Main extends App {
class Funky[A, B](val foo: A, val bar: B) {
override def toString: String = s"Funky($foo, $bar)"
cvasani /
Created May 14, 2019 — forked from jamesyang124/
Notes for programming in Scala 2nd edition.

#Note for Programming in Scala

##Chp.0 SBT & Scala Interpreter

  1. Call scala interpreter by sbt.

    // enter scala interpreter
cvasani / curl reference
Created Mar 3, 2019 — forked from afair/curl reference
Curl command reference with options sorted by category for easier usage than that man page.
View curl reference
Format curl [options] [URL...]
Quick Ref:
curl -X POST <= Method option and URL (Options come before or after URL)
-H "Authorization: <data>" <= Add HTTP Header (like Authorization)
cvasani / nqueen.scala
Created Aug 12, 2018 — forked from ornicar/nqueen.scala
solution to the n-queens problem based on "Programming in Scala"
View nqueen.scala
// Solves the n-queens problem for an arbitrary board size
// Run for a board size of ten: scala nqueen.scala 10
object Nqueen {
type Queen = (Int, Int)
type Solutions = List[List[Queen]]
def main(args: Array[String]) {
val size: Int = args match {
case Array() => sys.error("Provide a board size")
case Array(n) => n.toInt
cvasani / .block
Created Jul 11, 2018 — forked from mbostock/.block
Epicyclic Gearing
View .block
license: gpl-3.0

This cheat sheet originated from the forum, credits to Laurent Poulain. We copied it and changed or added a few things.

Evaluation Rules

  • Call by value: evaluates the function arguments before calling the function
  • Call by name: evaluates the function first, and then evaluates the arguments if need be
    def example = 2      // evaluated when called
    val example = 2      // evaluated immediately
cvasani / gist:6c74966f68fdb0e23e2e5c22b89fdba6
Created Nov 6, 2016 — forked from DavidWalz/gist:8538435
python: clopper pearson binomial confidence belt
View gist:6c74966f68fdb0e23e2e5c22b89fdba6
import scipy.stats
def clopper_pearson(k,n,alpha=0.32):
alpha confidence intervals for a binomial distribution of k expected successes on n trials
Clopper Pearson intervals are a conservative estimate.
lo = scipy.stats.beta.ppf(alpha/2, k, n-k+1)
hi = scipy.stats.beta.ppf(1 - alpha/2, k+1, n-k)
return lo, hi
cvasani /
Created Nov 3, 2016 — forked from mbostock/
Underscore’s Equivalents in D3



Underscore example:

_.each([1, 2, 3], function(num) { alert(num); });
You can’t perform that action at this time.