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 / mvn-grep-deps-libraries-bom.bash
Created November 17, 2021 18:32
A small bash script which specifies the maven (mvn) command to list resolution of those artifacts from `com.google.cloud:libraries-bom`
#!/bin/bash
function main () { (
includePatterns=(
"com.google.apis.grpc:*" # generated grpc and proto libraries
"com.google.api:*" # gax, api-common, etc.
"com.google.api-client:*" # api client between discovery doc clients and http-client
"com.google.apis:*" # discovery doc generated clients
"com.google.auth:*" #
"com.google.cloud:*" # "clients" gapics/veneers
@BenWhitehead
BenWhitehead / a_Parent.java
Last active June 24, 2017 00:54
Static method shadowing
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class Parent {
private static final Logger LOGGER = LoggerFactory.getLogger(Parent.class);
@BeforeClass
public static void beforeClass() {
@BenWhitehead
BenWhitehead / 01_README.md
Last active November 1, 2016 23:55
Import CloudFront access logs into Redshift

CloudFront access log Import

SQL Template and Script that can be used to import access logs generated by CloudFront and stored in an s3 bucket.

The script uses psql to run the import script against Redshift, so the script should be ran in a location where psql is on the PATH such as postgres:9.4

Expected Environment Variables

var description
object HelloPixel {
def main(args: Array[String]): Unit = {
val chars = Seq(
"01010100", "01101000", "01100101", "00100000", "01101110",
"01100101", "01111000", "01110100", "00100000", "01100011",
"01101000", "01100001", "01110000", "01110100", "01100101",
"01110010", "00100000", "01101001", "01110011", "00100000",
"01101000", "01100101", "01110010", "01100101", "00101110"
).map(Integer.valueOf(_, 2)).map(_.toChar)
println(chars.mkString(""))
@BenWhitehead
BenWhitehead / add-to_evaluateOffer.java
Created October 8, 2015 02:46
Cassandra-Mesos Dynamic reservation
final Optional<TaskResources> reserveResourcesForHost = cassandraCluster.shouldCreateReservation(marker, offer);
if (reserveResourcesForHost.isPresent()) {
final TaskResources res = reserveResourcesForHost.get();
final List<Resource> resources = newArrayList(
reserveCpu(res.getCpuCores(), mesosRole, principal),
reserveMem(res.getMemMb(), mesosRole, principal),
reserveDisk(res.getDiskMb(), mesosRole, principal),
reservePorts(res.getPortsList(), mesosRole, principal)
);
final Offer.Operation reservation = Offer.Operation.newBuilder()
@BenWhitehead
BenWhitehead / _etc_systemd_system_powertop.service
Created February 20, 2015 00:39
systemd powertop unit file ||| laptop power config linux
[Unit]
Description=Powertop tunings
[Service]
Type=oneshot
Environment=TERMINFO=/etc/terminfo
Environment=TERM=linux
ExecStart=/usr/sbin/powertop --auto-tune
[Install]
@BenWhitehead
BenWhitehead / a.scala
Created January 20, 2015 19:54
Scala Type check Try Success parameter
import org.scalatest.FreeSpec
import scala.reflect.ClassTag
import scala.util.{Failure, Success, Try}
class Data(a: => AnyRef) {
def get() = a
}
class TypeCheckingBranches extends FreeSpec {
@BenWhitehead
BenWhitehead / readme.md
Last active August 29, 2015 14:11
Bash script to "run" a marthon.json manifest that contains a docker image.

A script that reads a marathon json manifest and turns it into the local representation to run the docker image.

Install

Install script to a location in your path (~/bin), Make it executable chmod +x run-marathon-json.

Usage:

run-marathon-json marathon.json

Dependencies

@BenWhitehead
BenWhitehead / logback.xml
Last active August 29, 2015 14:09
Logback configuration for rolling file appender
<configuration scan="true" scanPeriod="30 seconds">
<contextListener class="ch.qos.logback.classic.jul.LevelChangePropagator">
<resetJUL>true</resetJUL>
</contextListener>
<appender name="FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>app.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.FixedWindowRollingPolicy">
<fileNamePattern>app.log.%i.zip</fileNamePattern>
@BenWhitehead
BenWhitehead / ansible-iptables.yml
Created September 30, 2014 21:16
Ansible iptables commands for http(s) routing
---
- name: iptables open 443
command: iptables -A INPUT -i eth0 -p tcp --dport 443 -j ACCEPT
- name: iptables 443 -> 8443
command: iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443
- name: iptables open 80
command: iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT