Skip to content

Instantly share code, notes, and snippets.

View BenWhitehead's full-sized avatar

BenWhitehead BenWhitehead

  • Google
  • New York City, New York
View GitHub Profile
@BenWhitehead
BenWhitehead / gist:9335321
Last active August 29, 2015 13:56
`jq` map a JSON array to a JSON object indexed by 'id'
## deps: httpie, jq
http GET http://api.example.domain/resource | jq '[.[] | {key: (.id | tostring), value: .}] | from_entries'
@BenWhitehead
BenWhitehead / teamcity-agent.service
Created March 7, 2014 23:09
systemd service files for running TeamCity (create in /usr/lib/systemd/system)
[Unit]
Description=TeamCity Build Agent
After=network.target
[Service]
Type=forking
PIDFile=$AGENT_HOME/logs/buildAgent.pid
ExecStart=/usr/bin/sudo -u teamcity $AGENT_HOME/bin/agent.sh start
ExecStop=/usr/bin/sudo -u teamcity $AGENT_HOME/bin/agent.sh stop
@BenWhitehead
BenWhitehead / gist:9532555
Last active August 29, 2015 13:57
IntelliJ IDEA Font anti-aliasing settings
echo "-Dswing.aatext=true" >> $IDEA_HOME/bin/idea.properties
echo "-Dawt.useSystemAAFontSettings=on" >> $IDEA_HOME/bin/idea.properties
@BenWhitehead
BenWhitehead / trim-patch.bash
Created March 25, 2014 16:36
A shell pipeline to get only the modified lines from a patch (useful to count actual number of lines changed in a patch)
# select lines that begin with + or -, remove lines that start with +++, remove lines that start with ---
grep "^[+-]" full.patch | grep -v "^+++" | grep -v "^---" > trim.patch
@BenWhitehead
BenWhitehead / forkAndWait.bash
Created April 7, 2014 17:55
Fork some process and wait for all forks to complete
#!/bin/bash
PIDS=""
function fork() {
echo "sleeping ${1}s" && sleep ${1}s && echo "slept ${1}s" &
PIDS="${PIDS} $!"
}
fork 2
fork 4
fork 8
@BenWhitehead
BenWhitehead / .bashrc
Last active July 31, 2020 18:32
server tmux config
# Sample .bashrc for SuSE Linux
# Copyright (c) SuSE GmbH Nuernberg
# There are 3 different types of shells in bash: the login shell, normal shell
# and interactive shell. Login shells read ~/.profile and interactive shells
# read ~/.bashrc; in our setup, /etc/profile sources ~/.bashrc - thus all
# settings made here will also take effect in a login shell.
#
# NOTE: It is recommended to make language settings in ~/.profile rather than
# here, since multilingual X sessions would not work properly if LANG is over-
@BenWhitehead
BenWhitehead / TwitterFinagleExperimentation.scala
Last active August 29, 2015 14:04
Scala Twitter Try Testing and Finagle Experimentation
import com.twitter.finagle.{Filter, Service}
import com.twitter.util.{Await, Future}
import io.finch.AnyOps
object test {
def main(args: Array[String]) {
val s = "12345"
val s1 = new Service1
@BenWhitehead
BenWhitehead / FutureTest.scala
Last active August 29, 2015 14:05
scala future testing
import java.util.concurrent.Executors
import org.scalatest.FreeSpec
import scala.concurrent.{Future, Await, ExecutionContext}
import scala.concurrent.duration.DurationInt
import scala.util.Try
/**
* @author Ben Whitehead
@BenWhitehead
BenWhitehead / per-testing.log
Created August 20, 2014 20:39
logging performance difference when running in docker
##### Logging to stdout #######################################################
benw@m02:~/wrk$ ./wrk -t4 -c100 -d30s http://s07.dev.orch.msphere.co:31713/test
Running 30s test @ http://s07.dev.orch.msphere.co:31713/test
4 threads and 100 connections
Thread Stats Avg Stdev Max +/- Stdev
Latency 33.38ms 97.26ms 677.79ms 97.61%
Req/Sec 1.36k 311.38 1.94k 85.13%
161734 requests in 30.00s, 11.41MB read
Requests/sec: 5391.33
@BenWhitehead
BenWhitehead / java.log
Created September 21, 2014 04:01
twitter-server classload log
[Opened $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.lang.Object from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.io.Serializable from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.lang.Comparable from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.lang.CharSequence from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.lang.String from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.lang.reflect.GenericDeclaration from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.lang.reflect.Type from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.lang.reflect.AnnotatedElement from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]
[Loaded java.lang.Class from $HOME/opt/java/jdk1.7.0_67/jre/lib/rt.jar]