Skip to content

Instantly share code, notes, and snippets.

View bpholt's full-sized avatar

Brian P. Holt bpholt

View GitHub Profile
@bpholt
bpholt / rm.js
Last active April 9, 2016 20:21
Remove Jenkins secondary nodes gone out of control
for (node in hudson.model.Hudson.instance.slaves.take(100)) {
println(node.name)
node.getComputer().setTemporarilyOffline(true,null);
node.getComputer().doDoDelete();
}
println(hudson.model.Hudson.instance.slaves.size());
for (node in hudson.model.Hudson.instance.slaves.take(10)) {
computer = node.getComputer();
if(computer != null && computer.isOffline()) {
package com.dwolla.http.finagle
import com.twitter.finagle.Http.Client
import com.twitter.finagle.http.{Method, Request, Response}
import com.twitter.finagle.loadbalancer.LoadBalancerFactory
import com.twitter.finagle.{Http, Service}
object FinagleHttpClient {
private def newService(dest: String): Service[Request, Response] = {
@bpholt
bpholt / deregister.sh
Created November 4, 2015 22:14
Stop tasks on ECS Container Instance and Deregister it from ECS Cluster
#!/bin/bash
cluster=default
container_instance= # container instance guid
tasks=$(aws --region us-west-2 ecs list-tasks --container-instance $container_instance --cluster $cluster | jq -r '.taskArns | map(.[40:]) | reduce .[] as $item (""; . + $item + " ")')
for task in $tasks; do
aws --region us-west-2 ecs stop-task --task $task --cluster $cluster
done
aws --region us-west-2 ecs deregister-container-instance --cluster $cluster --container-instance $container_instance
@bpholt
bpholt / gist:07752883f30cc4595d8d
Created November 4, 2015 16:10
Consul Registrator service name environment variables of all running Docker containers
docker inspect $(docker ps -q) | \
jq 'map(.Config.Env |
map(select((. | startswith("SERVICE")) and
(. | startswith("SERVICE_IGNORE") | not)))) |
reduce .[] as $item ([]; . + $item)'
@bpholt
bpholt / ecs-cluster-cpu.sh
Last active October 7, 2015 20:07
Retrieve registered and remaining CPU resources in an Amazon ECS cluster
#!/bin/sh
aws ecs describe-container-instances \
--region ${REGION} \
--cluster ${CLUSTER} \
--container-instances $(aws ecs list-container-instances \
--region ${REGION} \
--cluster ${CLUSTER} | \
jq -r '.containerInstanceArns |
map(match("container-instance/(.*)").captures[].string)[]') | \
@bpholt
bpholt / TestActorHelpers.scala
Last active August 29, 2015 14:17
Actor test helpers
import akka.testkit.TestActorRef
object TestActorHelpers {
def queueMessagesTo(pausedActor: TestActorRef[Nothing])(sendMessages: => Unit) = {
pausedActor.suspend()
sendMessages
pausedActor.resume(null)
}
}
@bpholt
bpholt / pipeline.sbt
Created February 23, 2015 20:33
SBT Pipeline
lazy val pipeline = TaskKey[Unit]("pipeline", "Runs the full build pipeline: compile, test, integration tests")
pipeline <<= (test in IntegrationTest).dependsOn(test in Test)
@bpholt
bpholt / keybase.md
Created January 25, 2015 22:29
Keybase.io Verification

Keybase proof

I hereby claim:

  • I am bpholt on github.
  • I am bpholt (https://keybase.io/bpholt) on keybase.
  • I have a public key whose fingerprint is 525E 6B7F 3661 69C0 DA65 06EF 9F39 C3CD 3382 E6FC

To claim this, I am signing this object:

@bpholt
bpholt / touchGlobalPreferences.sh
Created May 11, 2014 23:54
May fix 3/4 finger multitouch when it stops working
touch ~/Library/Preferences/ByHost/.GlobalPreferences.*.plist