Skip to content

Instantly share code, notes, and snippets.

@jameskbride
jameskbride / HTTBuilderBinary.groovy
Created September 29, 2012 14:26
HTTPBuilder Binary Response Example
def getBinaryStream(params) {
def data
def http = new HTTPBuilder("http://google.com/baseURI")
http.request(Method.GET, ContentType.BINARY) {req ->
//uri.path = "/a/relative/path/here"
uri.port = "8080"
uri.query = [userName: "user", password:"password"]
headers.'User-Agent' = 'Mozilla/5.0'
headers.'Accept' = 'application/octet-stream'
response.'200' = {resp, binary ->
@jameskbride
jameskbride / bashrc_ps1_snippet.sh
Created April 13, 2013 14:12
Bash PS1 prompt with git branch info and color.
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[33m\]$(__git_ps1 "(%s)")\[\033[00m\]\$ '
@jameskbride
jameskbride / babysitter_kata
Created April 29, 2013 16:23
Babysitter Kata
Babysitter Kata
Background
----------
This kata simulates a babysitter working and getting paid for one night. The rules are pretty straight forward:
The babysitter
- starts no earlier than 5:00PM
- leaves no later than 4:00AM
- gets paid $12/hour from start-time to bedtime
@jameskbride
jameskbride / CMakeLists.txt
Last active May 23, 2018 19:29
Basic CMakeLists.txt for a "Hello, World!" C++ project. It shows the use of a library which contains the class file for the application.
cmake_minimum_required (VERSION 2.8)
project (CMakeHelloWorld)
#version number
set (CMakeHelloWorld_VERSION_MAJOR 1)
set (CMakeHelloWorld_VERSION_MINOR 0)
#include the subdirectory containing our libs
add_subdirectory (Hello)
@jameskbride
jameskbride / vending_machine_kata.md
Created September 3, 2014 21:51
Vending Machine Kata

Vending Machine kata blatantly copied from Guy Royse (https://github.com/guyroyse/vending-machine-kata)

Vending Machine Kata

In this exercise you will build the brains of a vending machine. It will accept money, make change, maintain inventory, and dispense products. All the things that you might expect a vending machine to accomplish.

The point of this kata to to provide an larger than trivial exercise that can be used to practice TDD. A significant portion of the effort will be in determining what tests should be written and, more importantly, written next.

@jameskbride
jameskbride / .gitconfig
Last active November 23, 2022 13:29
git tree alias
[alias]
tree = log --pretty=format:'%Cgreen%h%Creset -%C(auto)%d%Creset %s %C(cyan)<author:%an | %ai>%Creset' --graph --color --all --decorate
@jameskbride
jameskbride / trend_kata.md
Last active November 13, 2015 18:33
Trend Kata

Trend Kata

The trend kata is an exercise in determining the 'trend' of a series of numbers. The algorithm is weighted towards non-zero values and numbers in the series that are changing. A value of zero and numbers in sequence that are the same value, are given less weight in the calculation. The algorithm will be a summing of results, for each pair within the list, shifted by one (1).

This algorithm, will expect a list of numbers... whole numbers and/or decimals.

  • if the supplied list is empty or does not exist (null), then the trend calculator should return null.
  • if the list contains only a single value, then the trend calculator should return a value of zero (0).
  • the resulting trend will always start with a value of zero (0).
  • the first pair will contain the first two numbers in the list
@jameskbride
jameskbride / least-resistance.md
Created July 4, 2016 12:07
Path of Least Resistance Kata

Path of Least Resistance

The Challenge

Energy flows through the path of least resistance. For this challenge, you are provided a grid of integers where each integer represents the amount of resistance encountered at a given point on the grid. Energy enters the grid from the left (at any point) and passes through the grid to the right, moving only one column per round.

Programming Challenge

Movement is always to an adjacent row, meaning energy can flow horizontally or

@jameskbride
jameskbride / load_aws_credentials.sh
Created May 26, 2018 21:11
Load AWS credentials into environment variables
env AWS_ACCESS_KEY_ID=$(aws configure get aws_access_key_id) AWS_SECRET_ACCESS_KEY=$(aws configure get aws_secret_access_key)
@jameskbride
jameskbride / fetch-all-remote-branches.sh
Created December 27, 2020 15:29
Fetch all remote branches
#!/bin/bash
git checkout --detach
git fetch origin '+refs/heads/*:refs/heads/*'