Thread pools on the JVM should usually be divided into the following three categories:
- CPU-bound
- Blocking IO
- Non-blocking IO polling
Each of these categories has a different optimal configuration and usage pattern.
Count empty values in csv file, grouped by column with pandas
Reference: Data Cleaning with Python and Pandas: Detecting Missing Values
import scala.collection._ | |
import com.twitter.util._ | |
scala> val buffer = mutable.ArrayBuffer.empty[Int] | |
scala> println(Time.measure { (0 to 50000000).foreach { buffer += _ } }.inMillis) | |
17610 | |
scala> var vector = immutable.Vector.empty[Int] | |
scala> println(Time.measure { (0 to 50000000).foreach { vector :+= _ } }.inMillis) | |
7865 |
Copyright © 2016-2018 Fantasyland Institute of Learning. All rights reserved.
A function is a mapping from one set, called a domain, to another set, called the codomain. A function associates every element in the domain with exactly one element in the codomain. In Scala, both domain and codomain are types.
val square : Int => Int = x => x * x
#!/usr/bin/env bash | |
# lists all unused AWS security groups. | |
# a group is considered unused if it's not attached to any network interface. | |
# requires aws-cli and jq. | |
# all groups | |
aws ec2 describe-security-groups \ | |
| jq --raw-output '.SecurityGroups[] | [.GroupName, .GroupId] | @tsv' \ | |
| sort > /tmp/sg.all |
public class Constants { | |
/** | |
* Contains the path to your Lambda function code. | |
*/ | |
public static final String LAMBDA_TASK_ROOT = System.getenv("LAMBDA_TASK_ROOT"); | |
/** | |
* The environment variable is set to one of the following options, depending on the runtime of the Lambda function: | |
* AWS_Lambda_nodejs, AWS_Lambda_nodejs4.3, AWS_Lambda_nodejs6.10 |
// Use Gists to store code you would like to remember later on | |
console.log(window); // log the "window" object to the console |
import scala.slick.lifted.CanBeQueryCondition | |
// optionally filter on a column with a supplied predicate | |
case class MaybeFilter[X, Y](val query: scala.slick.lifted.Query[X, Y]) { | |
def filter[T,R:CanBeQueryCondition](data: Option[T])(f: T => X => R) = { | |
data.map(v => MaybeFilter(query.filter(f(v)))).getOrElse(this) | |
} | |
} | |
// example use case | |
import java.sql.Date |
// get handle to build output | |
def config = new HashMap() | |
def bindings = getBinding() | |
config.putAll(bindings.getVariables()) | |
def out = config['out'] | |
for (aSlave in hudson.model.Hudson.instance.slaves) { | |
// check if executor is dead | |
execList = aSlave.getComputer().getExecutors() | |
for( exec in execList ) { |