Skip to content

Instantly share code, notes, and snippets.

View tovbinm's full-sized avatar
<typing sounds>

Matthew Tovbin tovbinm

<typing sounds>
View GitHub Profile
tovbinm / FaunaDBTesting.scala
Last active April 18, 2020 02:00
FaunaDB container testing trait for Scala
import{ InetSocketAddress, Socket }
import java.time.Duration
import java.time.temporal.ChronoUnit.SECONDS
import java.util.concurrent.{ TimeUnit, TimeoutException }
import java.util.function.{ Consumer, Predicate }
import com.dimafeng.testcontainers.{ Container, GenericContainer }
import com.faunadb.client.FaunaClient
import org.junit.runner.Description
tovbinm / fauna-graphql-relations.gql
Last active March 6, 2022 14:38
FaunaDB Relations: GraphQL schemas, mutations and resulting documents
**** FaunaDB Relations: GraphQL schemas, mutations and resulting documents *
**** One to One Relation ***************************************************
type User { name: String! car: Car }
type Car { plate: String! owner: User }
mutation Create {
createUser(data: {
tovbinm /
Created December 20, 2017 04:25
Apply git patch safely with rejects
git format-patch HEAD~X --stdout > patch
git apply --stat patch
git apply --reject --whitespace=fix patch
tovbinm / udfs.scala
Last active June 29, 2017 21:33
Codegen dies (Spark 2.0.2 and 2.1.1) - no udf nesting
import spark.implicits._
import org.apache.spark.sql.functions.udf
import org.apache.spark.sql._
import org.apache.spark.sql.functions._
import org.apache.spark.sql.execution.debug._
val u = udf((a: Int) => a)
val df = spark.sparkContext.parallelize(Seq(0)).toDF("0")
val res = (1 until 20).foldLeft(df) { case (d, i) =>
package rs
import scala.language.higherKinds
import matryoshka.implicits._
import scalaz._, Scalaz._
trait Expr[A]
case class NumLit[A](value: Int) extends Expr[A]
tovbinm / 01-iptables.config
Created July 22, 2016 18:03
Piercing IPTables for Akka Cluster on AWS Beanstalk with ebextensions
mode: "000644"
content: |
description "Elastic Beanstalk Default Docker Container Iptables"
author "Matthew Tovbin <>"
start on started docker
stop on stopping docker
tovbinm / build.gradle
Last active April 27, 2016 17:15
Scala repl with Gradle
task classpath << {
description 'Print project classpath.'
println sourceSets.main.runtimeClasspath.asPath
tovbinm /
Created February 25, 2015 17:25
Changing ulimit for running processes
cd /proc/<pid> && echo -n "Max open files=65535:65535" > limits
tovbinm / FileAsyncIO.scala
Last active March 15, 2021 10:43
File Async IO for Scala
import java.nio.ByteBuffer
import java.nio.channels.{AsynchronousFileChannel, CompletionHandler}
import java.nio.file.Paths
import java.nio.file.StandardOpenOption._
import scala.concurrent.{ExecutionContext, Future, Promise}
import scala.util.Try
tovbinm /
Last active August 29, 2015 13:59
A handy Statsd trap that outputs all the incoming traffic to console
import socket, select
s1 = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s1.bind(('localhost', 8125))
s2 = socket.socket(socket.AF_INET, socket.SOCK_RAW, socket.IPPROTO_UDP)
s2.bind(('localhost', 8125))
while True:
r, w, x =[s1, s2], [], [])
for i in r:
print i, i.recvfrom(131072)