Skip to content

Instantly share code, notes, and snippets.

View johnbuhay's full-sized avatar
📺
Working from New York

John Buhay johnbuhay

📺
Working from New York
View GitHub Profile
@johnbuhay
johnbuhay / one-liners
Last active August 29, 2015 14:23
Particularly fond of these useful one liners:
# Get a version from a json:
REMOTE_VERSION=$(curl -s URL_THAT_RETURNS_JSON|python -c 'import json,sys;obj=json.load(sys.stdin);print obj["version"]')
# Get latest version from Artifactory:
REMOTE_VERSION=$(curl -s http://{{artifactory_integration_host}}:8081/artifactory/api/npm/libs-npm-virtual/ww-node-configs/latest|python -c 'import json,sys;obj=json.load(sys.stdin);version = "0.0.0" if obj.get("version") is None else obj["version"];print version')
# To stop a job in jenkins if this build is not for a newer version:
python -c 'import sys; exit(0) if sys.argv[1] > sys.argv[2] else exit(1)' $LOCAL_VERSION $REMOTE_VERSION
git_move() { # where $1 is your origin name and $2 is the new origin url
git fetch --all
git pull --all
for b in `git branch -r | grep -v -- '->'`; do git branch --track ${b##origin/} $b; done
git remote remove $1
git remote add $1 $2
for b in `git branch | grep -v -- '*'`; do git push -u origin $b; done
git push --tags
}
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg)$ {
log_not_found off;
proxy_cache_valid any 1m;
proxy_pass http://local_backend$uri$is_args$args;
add_header X-Proxy-Cache $upstream_cache_status;
}
@johnbuhay
johnbuhay / setup-users.groovy
Created January 21, 2016 01:15
jenkins init.groovy.d script for configuring users
import jenkins.*
import hudson.*
import com.cloudbees.plugins.credentials.*
import com.cloudbees.plugins.credentials.common.*
import com.cloudbees.plugins.credentials.domains.*
import com.cloudbees.jenkins.plugins.sshcredentials.impl.*
import hudson.plugins.sshslaves.*;
import hudson.model.*
import jenkins.model.*
import hudson.security.*
@johnbuhay
johnbuhay / dogsitter.py
Created February 5, 2016 15:23
Restart Datadog agent automatically inside docker when python script detects integration changes
#!/opt/datadog-agent/embedded/bin/python
import os
import sys
import time
import re
import subprocess
import logging
# To keep this lightweight we assume the following
FROM golang
WORKDIR /go
RUN go get github.com/BurntSushi/toml && \
go get github.com/kelseyhightower/confd && \
cd $GOPATH/src/github.com/kelseyhightower/confd && \
git remote add sort https://github.com/HeavyHorst/confd.git && \
git pull sort sort && git checkout sort && \
find / -type f -name "*confd" -exec rm {} \; && \
@johnbuhay
johnbuhay / docker-compose.yml
Last active April 3, 2016 21:14
Further testing confd with json values
---
confd:
build: .
links:
- etcd
volumes:
- ${PWD}/example.tmpl:/etc/confd/templates/example.tmpl
environment:
@johnbuhay
johnbuhay / bash log-util
Created April 9, 2016 02:59
Useful bash scripts
#!/bin/bash
# This script should be sourced
case "$LOG_LEVEL" in
debug)
set -x
LOG_DEBUG="DEBUG"
LOG_VERBOSE="VERBOSE"
LOG_MESSAGE="MESSAGE"
@johnbuhay
johnbuhay / Curl_commands.md
Last active January 30, 2017 15:14
useful curl commands

Design pattern for how gists are labelled.