Instantly share code, notes, and snippets.

View kill_deploy_jobs.groovy
import hudson.model.*
def q = Jenkins.instance.queue
q.items.each {
if (it =~ /deploy-to/) {
View groovy.groovy
def cmd = 'hostname'
def sout = new StringBuffer(), serr = new StringBuffer()
def proc = cmd.execute()
proc.consumeProcessOutput(sout, serr)
println sout

Pull Request Etiquette

Why do we use a Pull Request workflow?

PRs are a great way of sharing information, and can help us be aware of the changes that are occuring in our codebase. They are also an excellent way of getting peer review on the work that we do, without the cost of working in direct pairs.

Ultimately though, the primary reason we use PRs is to encourage quality in the commits that are made to our code repositories

Done well, the commits (and their attached messages) contained within tell a story to people examining the code at a later date. If we are not careful to ensure the quality of these commits, we silently lose this ability.



Services declared as oneshot are expected to take some action and exit immediatelly (thus, they are not really services, no running processes remain). A common pattern for these type of service is to be defined by a setup and a teardown action.

Let's create a example foo service that when started creates a file, and when stopped it deletes it.

Define setup/teardown actions

Create executable file /opt/foo/

DESCRIPTION="bad things™ are happening"
if [ $# -ne 3 ]; then
echo " - TYPE: [t]rigger | [a]cknowledge | [r]esolve"
echo " - SERVICE KEY: unique identifier for service"
Code adapted from and inspired by
import os
import re
from datetime import datetime, timedelta
import boto3
View Get Jenkins GDSL working with IntelliJ IDEA
1. Setup a project
2. Add groovy SDK support:
3. Download http://(yourjenkinsurl)/job/(yourpipelinejob)/pipeline-syntax/gdsl
- this will give you the .gdsl file - download this to the src folder of your project.
4. Finally follow this step - right click on the src folder -> Mark directory as -> Sources Root
import time
from boto.ec2.autoscale import AutoScaleConnection
def find_unused_launch_configs():
conn = AutoScaleConnection()
autoscale_groups = conn.get_all_groups(max_records=100)
launch_configs = conn.get_all_launch_configurations(max_records=100)
launch_config_names = { for lc in launch_configs}
View Mathletics Hack Code
var time = 60; var clock = 300; function TimeHack(){
setInterval(function Applytime() {
document.getElementsByClassName('timerLabel whiteTextWithShadow font-60 ng-binding')["0"].innerText = time; document.getElementsByClassName('timerLabel whiteTextWithShadow font-60 ng-binding')["0"].innerHtml = time;
document.getElementsByClassName('clockHand').rotate = clock;
}, 1);}; function TimeHackm() {
setInterval(function Addtime() {
time = time + 1;
clock = clock + 6;
}, 1000);}
var score = 1;
View aws-s3-policy-minimum-privs.txt
"Version": "2012-10-17",
"Statement": [
"Sid": "statement1",
"Effect": "Allow",
"Action": [