Skip to content

Instantly share code, notes, and snippets.

View janschumann's full-sized avatar

Jan Schumann janschumann

View GitHub Profile
@janschumann
janschumann / exec.sh
Created February 27, 2019 19:55
Execute command in multiple directories in parallel
#!/bin/bash
# example: run puppet tests in all modules
CMD="pdk test unit --format=junit:report.xml &> pdk_test.log"
for d in $(ls -d); do {
cd $d
$CMD & pid=$!
PID_LIST+=" $pid";
cd ..
@janschumann
janschumann / gist:3a457452805b1499bbbdb28275230526
Created February 4, 2019 18:06
New Relic: Notifiy deployment
APP_NAME="<app name from newrelic.cnf"
NEW_RELIC_APP_ID=$(curl --silent -X GET 'https://api.newrelic.com/v2/applications.json' -H "X-Api-Key:${NEW_RELIC_API_KEY}" -G -d "filter[name]=${APP_NAME}" | jq -r '.applications[].id')
if [ -n $NEW_RELIC_APP_ID ]; then
curl -X POST "https://api.newrelic.com/v2/applications/${NEW_RELIC_APP_ID}/deployments.json" \
-H "X-Api-Key:${NEW_RELIC_API_KEY}" -i \
-H 'Content-Type: application/json' \
-d \
"{
\"deployment\": {
@janschumann
janschumann / create_volume.sh
Created November 24, 2018 21:10
LVM commands
# create physical volume
pvcreate /dev/<volume_name>
# create volume group
vgcreate <group_name> /dev/<volume_name>
# create volume
lvcreate -L <size>G -n <volume_name> <group_name>
# create fs
@janschumann
janschumann / pretty.js
Created February 5, 2016 14:01
Read JSON from stdin and pretty print
var json = "";
process.stdin.setEncoding('utf8');
process.stdin.on('readable', () => {
var chunk = process.stdin.read();
if (chunk !== null) {
json += `${chunk}`;
}
});
@janschumann
janschumann / gist:e9bb6a0298101a465d94
Created February 6, 2015 14:47
Install omniout_crowd with gitlab via puppet
file_line { 'omniauth_crowd-gem':
path => '/opt/gitlab/embedded/service/gitlab-rails/Gemfile',
line => 'gem "omniauth_crowd", "2.2.2"',
require => Package['gitlab']
}
file_line { 'patch-devise-rb':
path => '/opt/gitlab/embedded/service/gitlab-rails/config/initializers/devise.rb',
line => " provider_arguments << provider['args'].symbolize_keys",
match => "^ provider_arguments << provider\\['args'\\]\$",
@janschumann
janschumann / gist:9260598
Created February 27, 2014 22:05
Remove all remote repos from local repo
for b in $(git branch -r); do
if test $b != "origin/HEAD" -a $b != "origin/master" -a $b != "->"; then
git branch -rd $b
fi;
done
git gc --aggressive
@janschumann
janschumann / git-tracks
Created February 12, 2014 19:35
find out which remote branch is tracked by the current branch
#!/bin/sh -e
# find out which remote branch is tracked by the current branch
branch=$(git symbolic-ref HEAD)
branch=${branch##refs/heads/}
remote=$(git config "branch.${branch}.remote")
remoteBranch=$(git config "branch.${branch}.merge")
remoteBranch=${remoteBranch##refs/heads/}