Skip to content

Instantly share code, notes, and snippets.

View aishfenton's full-sized avatar

Aish aishfenton

  • Netflix
  • San Francisco
View GitHub Profile
select regexp_extract(date_time,'[^T]*T([0-9][0-9])', 1), count(*)
from single_search
group by regexp_extract(date_time,'[^T]*T([0-9][0-9])', 1)
@aishfenton
aishfenton / gist:de1d18056b0311594d792add92dca3f2
Last active October 5, 2016 03:10
Scala gaps for Machine Learning
* Actively supported linear alg library ;)
* Good optimization libraries.
* Better low-level GPU libaries. JCuda, but better.
* A feature-rich plotting library.
* Richer MCMC libaries.
@aishfenton
aishfenton / ArrayMap.scala
Created February 10, 2017 23:38
ArrayMap.scala
trait EnumMap[A, B] {
def apply(a: A): B
}
// Quick sketch, untested.
final class ArrayEnumMap[A, @spec B : ClassTag](xs: Seq[(A,B)]) extends EnumMap[A,B] {
val (keys, values) = mkEntries(xs)
val size = keys.length
@aishfenton
aishfenton / scopt-range-parser.scala
Created February 18, 2017 21:42
Scopt range parser
implicit val listIntRead: scopt.Read[List[Int]] =
scopt.Read.reads { str =>
val parts = str.split(",").map(_.trim).toList
parts.flatMap { p =>
if (p.contains("-")) {
val (start :: end :: Nil) = p.split("-").map(_.trim.toInt).toList
Range(start, end + 1).toList
}
else p.toInt :: Nil
}
@aishfenton
aishfenton / UnionType.scala
Last active December 10, 2019 22:15
Union Types for Scala
package union
/**
* Much magic. Very Lambda. Wow!
*
* These types provide union types (i.e. val a = (String or Int) within Scala. See here for good discussion on
* how to represent union types in Scala (hat tip Miles Sabin)
* http://stackoverflow.com/a/37450446/1591351
*
* Core idea is to adapt Demorgan's Law:
@aishfenton
aishfenton / serializer_benchmarks.rb
Created July 18, 2010 02:32 — forked from visfleet/performance_of_yaml_vs_marshal.rb
Performance comparison of different ruby serializer methods
# sudo gem install bson
# sudo gem install bson_ext
# sudo gem install yajl-ruby
# sudo gem install json
# sudo gem install msgpack
require 'rubygems'
require 'benchmark'
require 'yaml'
require 'bson'