Skip to content

Instantly share code, notes, and snippets.

View wrobstory's full-sized avatar

Rob Story wrobstory

View GitHub Profile
@wrobstory
wrobstory / gist:7b5777a2732729717cc7
Created August 25, 2014 18:38
Scala Default Args
scala> def addStringOneParam(input: String): String = input + "foo"
addStringOneParam: (input: String)String
scala> def addStringDefParam(input: String, toAdd: String = "foo"):String = input + toAdd
addStringDefParam: (input: String, toAdd: String)String
scala> addStringOneParam("baz")
res3: String = bazfoo
scala> addStringDefParam("baz")
@wrobstory
wrobstory / gist:934f9a261e1955a775ca
Created September 7, 2014 00:13
Scala Equality
scala> Array(1, 2, 3) == Array(1, 2, 3)
res0: Boolean = false
scala> Vector(1, 2, 3) == Vector(1, 2, 3)
res1: Boolean = true
scala> List(1, 2, 3) == List(1, 2, 3)
res2: Boolean = true
@wrobstory
wrobstory / gist:60750cec022650bf27b1
Created September 7, 2014 01:28
Import mutable
scala> Set
res0: scala.collection.immutable.Set.type = scala.collection.immutable.Set$@12559336
scala> import scala.collection.mutable.Set
import scala.collection.mutable.Set
scala> Set
res1: scala.collection.mutable.Set.type = scala.collection.mutable.Set$@f86a0bd
@wrobstory
wrobstory / gist:98033556dd590132852e
Created September 8, 2014 04:17
PIP ALL THE THINGS
#!/bin/bash
virtualenv .env &&
source .env/bin/activate &&
brew install libevent &&
brew install libyaml &&
pip install cython &&
pip install numpy &&
pip install scipy &&
pip install pandas &&
pip install matplotlib &&
Robs-MacBook-Pro:testenv robstory$ sh PIPALLTHETHINGS.sh
New python executable in .env/bin/python2.7
Also creating executable in .env/bin/python
Installing setuptools, pip...done.
Warning: libevent-2.0.21 already installed
Warning: libyaml-0.1.6 already installed
Downloading/unpacking cython
Downloading Cython-0.20.2-cp27-none-macosx_10_6_intel.macosx_10_9_intel.macosx_10_9_x86_64.whl (3.4MB): 3.4MB downloaded
Installing collected packages: cython
Successfully installed cython
(.env)Robs-MacBook-Pro:IScala-0.1 robstory$ ipython console --KernelManager.kernel_cmd='["java", "-jar", "lib/IScala.jar", "--profile", "{connection_file}", "--parent"]'
Python 2.7.8 (default, Aug 13 2014, 14:30:31)
Type "copyright", "credits" or "license" for more information.
IPython 2.2.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.
Welcome to Scala 2.10.2 (Java HotSpot(TM) 64-Bit Server VM, Java 1.7.0_67)
@wrobstory
wrobstory / gist:a352ff715d7c94042574
Created September 19, 2014 22:25
Scala pattern match
val vec1 = Vector(1, 2, 3)
val vec2 = Vector(3, 4, 5, 6, 7, 8)
val vec3 = Vector("foo", "bar", "baz")
val vec4 = Vector("one", Map("one" -> 1, "two" -> 2))
def match_vec(vec: Vector[Any]) {
vec match {
case Vector(_, _, 3) => println("Vector ends in 3!")
case Vector(3, _*) => println("Vector starts with three, has any number of elements!")
case Vector(_, "bar", _) => println("String Vector!")
class YoDawg(FacetGrid):
"""I got facets in your facets"""
def __init__(args, kwargs)
super(YoDawg, self).__init__(*args, **kwargs)
@wrobstory
wrobstory / malortapi.py
Last active August 29, 2015 14:06
Malort API
stats = malort.run('mydir/files', delimiter='|')
redshift_suggestions = malort.get_redshift_types(stats)
df = malort.get_dataframe(stats)
# OR
result = malort.run('mydir/files', delimiter='|')
redshift_suggestions = result.get_redshift_types()
df = result.get_dataframe()
@wrobstory
wrobstory / gist:28ce5fecb3a11dcea564
Last active August 29, 2015 14:07
Higher Order Wat
def add(x: Int, y: Int = 1): Int = x + y
def transform(z: Int, transformer: (Int, Int) => Int): Int = transformer(z)
// Exiting paste mode, now interpreting.
<console>:9: error: not enough arguments for method apply: (v1: Int, v2: Int)Int in trait Function2.
Unspecified value parameter v2.
def transform(z: Int, transformer: (Int, Int) => Int): Int = transformer(z)