Skip to content

Instantly share code, notes, and snippets.

@loa
loa / bash_script_logger.sh
Created February 16, 2015 11:43
Bash script logger
#!/bin/bash
exec 1> >(logger -s -t $(basename $0)) 2>&1
echo "hello world"
@loa
loa / keytool_import.sh
Last active August 29, 2015 14:15
Java keytool import cacert
#!/bin/bash
keytool \
-importcert \
-noprompt \
-keystore cacerts \
--storepass changeit \
-alias newcert \
-file /root/ca.pem
@loa
loa / semver.sh
Last active May 14, 2022 22:27
Bash Git SemVer Util
#!/bin/bash
# Author: Carl Loa Odin <[email protected]>
# https://gist.github.com/loa/435da12af9494a112daf
test_res=0
function get_git_version() {
version=$(git describe)
if [ $? -eq 128 ]; then
# Return initial version incase no tags is found
@loa
loa / yaml2json.sh
Created February 4, 2015 17:41
Yaml 2 Json
#!/bin/bash
python -c 'import sys, yaml, json; json.dump(yaml.load(sys.stdin), sys.stdout, indent=4)'
@loa
loa / rotateCursor.sh
Created January 21, 2015 13:53
Bash rotate cursor
#!/bin/bash
rotateCursor() {
s="-,\\,|,/"
for i in `seq 1 $1`; do
for i in ${s//,/ }; do
echo -n $i
sleep 1
echo -ne '\b'
done
@loa
loa / aws-upload-sshkey.sh
Last active August 29, 2015 14:10
AWS EC2 upload ssh pub to all regions
#!/bin/bash
# http://alestic.com/2010/10/ec2-ssh-keys
which aws > /dev/null 2>&1 || {
echo "ERROR: missing aws-cli"
echo "http://aws.amazon.com/cli/"
echo "$ brew install awscli"
exit 1
}
@loa
loa / git-diff-ignore-whitespace.sh
Created October 16, 2014 08:50
git diff ignore whitespace
git diff --ignore-space-at-eol -b -w --ignore-blank-lines
@loa
loa / osx-nosleep.sh
Last active August 29, 2015 14:07
OSX prevent sleep
alias nosleep='pmset noidle'
@loa
loa / jenkins-api.py
Created September 22, 2014 12:48
Python Jenkins API Auth
#!/usr/bin/env python
import base64
import os
import urllib2
username = os.environ['user']
password = os.environ['password']
@loa
loa / jenkins_xunit_blue-yellow-red.yaml
Last active August 29, 2015 14:06
Jenkins xunit blue-yellow-red
- job-template:
name: 'exitcode-{exitcode}-{testresult}'
builders:
- shell: |
#!/bin/bash -xe
if [ "{testresult}" = "passed" ]; then
STATUS="passed"
NUM_FAILURE="0"