Instantly share code, notes, and snippets.

View log.sh
NC='\033[0m'
function log_info {
green "INFO" "${1}"
}
function log_warn {
orange "WARN$" "${1}"
}
View ModuleEndpoints.scala
import play.api.mvc._
import play.api.routing.sird._
import play.api.routing.{Router, SimpleRouter}
object ModuleEndpoints extends SimpleRouter {
def routes: Router.Routes = {
case GET(p"/getendpoint") => Action { req =>
Results.Ok("/getendpoint in ModuleEndpoints")
}
}
View DataprocPlugin.scala
import sbt.Keys._
import sbt._
object DataprocPlugin extends AutoPlugin {
object autoImport {
val dataprocZone = settingKey[String]("Zone to run Dataproc cluster in")
val dataprocClusterName = settingKey[String]("Dataproc cluster name")
val dataprocServiceAccount = settingKey[String]("Service account to use for Dataproc cluster")
val createCluster = taskKey[Unit]("dataproc-start")
View install.R
pkgs <- c("RCurl", "jsonlite", "statmod", "devtools", "roxygen2", "testthat")
for (pkg in pkgs) {
if (! (pkg %in% rownames(installed.packages()))) install.packages(pkg)
}
View EternalInMemoryCache.scala
import java.util.concurrent.ConcurrentHashMap
class EternalInMemoryCache[A, B]{
private val underlying = new ConcurrentHashMap[A,B]()
def cached(key: A)(value: => B): B = {
Option(underlying.get(key)) match {
case Some(v) => v
case None =>
underlying.put(key, value)
value
}
View iterm2-solarized.md

Default

Default

Powerlevel9k

Powerlevel9k

View git_ammend_old.sh
#!/bin/bash
# Usage:
# ./git_ammend_old.sh <commit-sha>
# then we change pick to edit for this commit in interactive mode
set -evx
git stash && \
echo "REMEBER TO CHANGE THE COMMIT TO EDIT" && \
git rebase --interactive "${1}^" && \
View spark-debug-profile.md

Debugging locally run Spark application in IntelliJ

  • Add the following lines to your spark-submit command
--num-executors 1 \
--executor-cores 1 \
--conf "spark.executor.extraJavaOptions=-agentlib:jdwp=transport=dt_socket,server=n,address=localhost:5005,suspend=n" \
--driver-java-options -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005 \
  • Configure Run/Debug Configuration in Intellij: Remote -> default settings for localhost