Skip to content

Instantly share code, notes, and snippets.

View byrnedo's full-sized avatar

Donal Byrne byrnedo

View GitHub Profile
/* global grecaptcha */
/* global $ */
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['g-recaptcha'],
attributeBindings: ['siteKey:data-sitekey', 'data-theme', 'data-size', 'data-callback', 'data-expired-callback', 'data-tabindex'],
siteKey: '',
lang: 'sv',
resetTrigger: false,
@byrnedo
byrnedo / gnatsd_service_check.sh
Last active September 22, 2015 11:07
Check if one can get a response on a nats channel. I use it for health checking node services. Uses mailgun to email.
#!/bin/bash
set -ueo pipefail
natsUrl="nats://user:pass@192.168.1.84:4222"
checkTimeout=6
mailgunDomain=CHANGEME
mailgunAPIKey=CHANGEME
deliveryEmailAddress=CHANGEME
SEND_ERROR_MAIL=1
@byrnedo
byrnedo / clone_stash_project.sh
Last active September 22, 2015 11:05
Clone every repo in an Atlassian Stash project. Must run with env variables STASH_USER and STASH_PASSWORD set. Must also change url and git url.
#!/bin/bash
if [ $# -lt 1 ]
then
echo >&2 Must give project code as argument
exit 1
fi
string_project=$1
#CHANGEME
@byrnedo
byrnedo / dockerHelpers.bash
Last active July 3, 2020 08:15
Docker helpers ( simple colour docker ps )
RED=`echo -e '\033[101m\033[37m'`
GREEN=`echo -e '\033[102m'`
DARK_RED=`echo -e '\033[41m\033[37m'`
DARK_GREEN=`echo -e '\033[42m'`
NORMAL=`echo -e '\033[0m'`
#Docker aliases
function dps(){
docker ps --format "{{.ID}}\t{{.Image}}\t{{.Labels}}"| \
sed -e "s/:/ :/" | \
@byrnedo
byrnedo / staticDockerPortMapper.zsh
Last active October 29, 2015 15:10
Maps a dynamically allocated docker port to a chosen static port. Watches for updates.
func staticDockerPortMapper(){
[[ $# -lt 3 ]] && >&2 echo "usage: $0 <container-name/id> <exposed-container-port>/<tcp|udp> <static-port>" && return
local container=$1
local internalPort=$2
local staticPort=$3
local currentPid=$(lsof -ti :$staticPort 2>/dev/null)
if [[ -n $currentPid ]]
then
@byrnedo
byrnedo / startSwarm.sh
Last active February 5, 2017 22:08
Start 3 Machine Local Docker Swarm
#!/bin/bash
set -euo pipefail
function useDockerEnv {
eval "$(docker-machine env $1)"
}
function getIfaceIP {
local machine="$1"
@byrnedo
byrnedo / bash_iniparse.sh
Created January 20, 2016 08:21 — forked from splaspood/bash_iniparse.sh
Parsing INI Files with Bash
cfg.parser () {
fixed_file=$(cat $1 | sed 's/ = /=/g') # fix ' = ' to be '='
IFS=$'\n' && ini=( $fixed_file ) # convert to line-array
ini=( ${ini[*]//;*/} ) # remove comments
ini=( ${ini[*]/#[/\}$'\n'cfg.section.} ) # set section prefix
ini=( ${ini[*]/%]/ \(} ) # convert text2function (1)
ini=( ${ini[*]/=/=\( } ) # convert item to array
ini=( ${ini[*]/%/ \)} ) # close array parenthesis
ini=( ${ini[*]/%\( \)/\(\) \{} ) # convert text2function (2)
ini=( ${ini[*]/%\} \)/\}} ) # remove extra parenthesis
@byrnedo
byrnedo / fr.sh
Created January 21, 2016 07:53
Find Repo: Git repo fuzzy find (uses Fzf)
# Add this to your bashrc/zshrc somewhere
# Set env FR_SEARCH_PATH to where you want fr to start looking from, otherwise it starts at current dir.
function fd() {
local startDir=${FR_SEARCH_PATH:=.}
local dir
dir=$(cd $startDir && find . -name *.git -type d -nowarn 2>/dev/null | sed 's/\(.*\)\/.git/\1/' | fzf) && cd "$startDir/$dir"
}
@byrnedo
byrnedo / split_php_myadmin_export.sh
Created March 2, 2016 14:53
Splits a phpmyadmin sql export into one file per database. Requires a 'footer.sql' and 'header.sql' file for custom content.
#!/bin/bash
set -euo pipefail
mkdir -p ./out
rm -rf ./out/prod_split_*
csplit -n2 -s -f "out/" -b "prod_split_%d" $1 "/-- Database: /-1" "{*}"
rm -f ./out/prod_split_0
cd ./out
@byrnedo
byrnedo / check_docker_newer_tag.sh
Created April 7, 2016 07:08
Check if newer docker image available.
#!/bin/bash
# ensure running bash
if ! [ -n "$BASH_VERSION" ];then
echo "this is not bash, calling self with bash....";
SCRIPT=$(readlink -f "$0")
/bin/bash $SCRIPT
exit;
fi