Skip to content

Instantly share code, notes, and snippets.

@berngp
berngp / mesos-kpis.sh
Created March 1, 2014 02:46
Mesos KPIs
#!/usr/bin/env python
import collections
import datetime
import json
import signal
import sys
from contextlib import closing
from optparse import OptionParser
@berngp
berngp / .ctags
Last active August 29, 2015 13:57
Dot Files
--recurse=yes
--tag-relative=yes
--exclude=.git
--exclude='*/target/*'
--exclude=target
--exclude=vendor
--langdef=scala
--langmap=scala:.scala
--regex-scala=/^[ \t]*((abstract|final|sealed|implicit|lazy)[ \t]*)*((private|protected)(\[[a-zA-Z0-9_.]+\])?)?[ \t]*class[ \t]+([a-zA-Z0-9_]+)/\6/c,classes/
@berngp
berngp / spark-xshell.sh
Created March 21, 2014 06:36
Spark Extended Shell
#!/usr/bin/env bash
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
val r = 0.0 to 1.1 by 0.1
( ( r drop 2 ) drop 2 ) take 2 // doesn't work.
val r = BigDecimal(0.0) to 1.1 by 0.1
( ( r drop 2 ) drop 2 ) take 2 // does work.
@berngp
berngp / snippet_from_dot_zshrc.sh
Last active August 29, 2015 13:58
Dealing with Java 8 and 7 in the same Environment.
# snippet from my ~/.zshrc file.
export JAVA7_HOME="$(/usr/libexec/java_home -v 1.7)"
function with-jdk7
{
export JAVA_HOME="$JAVA7_HOME"
echo "$@"
$@
}
@berngp
berngp / ClientBase.scala
Created April 8, 2014 00:04
Bad Things On Code.
// somewhere inside some cool framework
val classpathEntries = Option(conf.getStrings(YarnConfiguration.YARN_APPLICATION_CLASSPATH)).
getOrElse(getDefaultYarnApplicationClasspath())
// where
def getDefaultYarnApplicationClasspath(): Array[String] = {
try {
val field = classOf[MRJobConfig].getField("DEFAULT_YARN_APPLICATION_CLASSPATH")
@berngp
berngp / diamond.scala
Last active August 29, 2015 13:58
Scala Scripts Exercises.
val width = 5
//width: Int = 5
val tTop = ( 0 until width/2 ) map ( n => 2 * n + 1 )
//tTop: scala.collection.immutable.IndexedSeq[Int] = Vector(1, 3)
val tBottom = tTop.reverse
//tBottom: scala.collection.immutable.IndexedSeq[Int] = Vector(3, 1)
val diamond = tTop union Seq(width) union tBottom
@berngp
berngp / git-patch-perfile.sh
Created April 30, 2014 22:51
Git Patch Per File
for x in $(find "src/java" -name "*.java"); do git format-patch master $x --stdout > "MESOS-1259-${x//\//-}" ; done
@berngp
berngp / feature_MESOS-1259.out
Last active August 29, 2015 14:00
Mesos Development Support Scripts (./support)
feature/MESOS-1259* → ./support/post-reviews-2.py
Running post-review across all of ...
369c6fa83ce3e6929646b1304bce918dc37b8274 - (HEAD, berngp/feature/MESOS-1259, feature/MESOS-1259) [MESOS-1259]:Enrich the Java Docs in the src/java files. -- ZooKeeperState.java (2 minutes ago)
7edb638b38c832040f9cf0b35a4ea79d1db8e389 - [MESOS-1259]:Enrich the Java Docs in the src/java files. -- Variable.java (2 minutes ago)
d8868252011c4653c856ef37a257eafa3112b0e9 - [MESOS-1259]:Enrich the Java Docs in the src/java files. -- State.java (2 minutes ago)
c1b9e284ba1ed79c50cdd53f0f66cd52a221217c - [MESOS-1259]:Enrich the Java Docs in the src/java files. -- SchedulerDriver.java (2 minutes ago)
cb4d252ac5863e58e63352748733d40faaf50b1c - [MESOS-1259]:Enrich the Java Docs in the src/java files. -- Scheduler.java (2 minutes ago)
f634fcd394273751dc8ee260d5485df384fc052c - [MESOS-1259]:Enrich the Java Docs in the src/java files. -- MesosSchedulerDriver.java (2 minutes ago)
2ac673c718a96f307ed288577d24b7a036045013 - [MESOS-1259]:Enric
@berngp
berngp / post-reviews.py
Last active August 29, 2015 14:00
Mesos support/post-reviews.py with support for PRTool 0.5.x and 0.6.x
#!/usr/bin/env python
# This is a wrapper around the 'post-review'/'rbt' tool provided by
# Review Board. This is currently used by Apache Mesos development.
#
# What does this do?
# It provides the ability to send a review for each commit on the
# current branch.
#
# Why is that useful?
# No one likes a 5000 line review request. Using this tool forces one