Skip to content

Instantly share code, notes, and snippets.

View jkinkead's full-sized avatar

Jesse Kinkead jkinkead

View GitHub Profile
import org.allenai.common.Config._
object ClassificationReader {
/** Reads classifications from disk, using the given config to find the classification file(s).
* This requires that the config have a key {classificationType}.file for each classification
* type.
* @throws IllegalArgumentException if any of the required keys are missing
*/
def readClassifications(config: Config): Seq[PaperClassification] = {
// Read a classification per file. This will generate PaperClassification instances with a
implicit val intMapFormat = new JsonFormat[Map[Int, Int]] = {
override def write(map: Map[Int, Int]): JsValue = {
map.toSeq.toJson
}
override def read(json: JsValue): Map[Int, Int] = json match {
case value: JsArray => value.convertTo[Seq[(Int, Int)]].toMap
case _: => "Expected . . . "
}
}
object Example {
val seq = Seq(1, 2, 3)
///////////
// RIGHT //
///////////
// You can either use parens:
val parens: Seq[Double] = seq.map(value => value + 1).map(value => value / 1.0)
// Or braces, which can look nicer for multi-line expressions:
@jkinkead
jkinkead / Dockerfile
Last active October 15, 2017 23:58
Naive Dockerfile
# You should always specify a full version here to ensure all of your developers
# are running the same version of Node.
FROM node:7.8.0
# The base node image sets a very verbose log level.
ENV NPM_CONFIG_LOGLEVEL warn
# Copy all local files into the image.
COPY . .
@jkinkead
jkinkead / .dockerignore
Last active May 18, 2024 14:57
Simple .dockerignore file for a create-react-app application
# Items that don't need to be in a Docker image.
# Anything not used by the build system should go here.
Dockerfile
.dockerignore
.gitignore
README.md
# Artifacts that will be built during image creation.
# This should contain all files created during `npm run build`.
build
@jkinkead
jkinkead / Dockerfile
Created April 10, 2017 19:14
Well-structured Dockerfile for a create-react-app application
# You should always specify a full version here to ensure all of your developers
# are running the same version of Node.
FROM node:7.8.0
# Override the base log level (info).
ENV NPM_CONFIG_LOGLEVEL warn
# Install and configure `serve`.
RUN npm install -g serve
CMD serve -s build
@jkinkead
jkinkead / deployment.yaml
Created September 7, 2017 20:57
HTTP echo server Deployment
kind: Deployment
metadata:
name: echo-service
labels:
application: echo-service
spec:
replicas: 1
template:
metadata:
labels:
@jkinkead
jkinkead / service.yaml
Created September 7, 2017 21:04
External HTTP+HTTPS Service
# Service definition for a http/https service.
apiVersion: v1
kind: Service
metadata:
name: echo-service
annotations:
# Note that the backend talks over HTTP.
service.beta.kubernetes.io/aws-load-balancer-backend-protocol: http
# TODO: Fill in with the ARN of your certificate.
service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:{region}:{user id}:certificate/{id}
@jkinkead
jkinkead / external_http_complete.yaml
Created September 7, 2017 21:06
Complete HTTP/HTTPS Deployment & Service
kind: Deployment
metadata:
name: echo-service
labels:
application: echo-service
spec:
replicas: 1
template:
metadata:
labels:
# Vim swap files.
.*.sw[p-z]
# Emacs backups.
*~
# OS X cache files.
.DS_Store
.Trashes
.Spotlight-V100