Skip to content

Instantly share code, notes, and snippets.

@sirkkalap
sirkkalap / InstallProxyTunnelUbuntu.sh
Last active August 18, 2016 08:07
This installs dependencies, checks out the Proxytunnel and builds it on Ubuntu.
# Use
# curl -sSL https://gist.githubusercontent.com/sirkkalap/3c11f952fea778110cfdb73ec3b97d8b/raw/InstallProxyTunnelUbuntu.sh | bash -x
sudo apt-get -y install libssl-dev
git clone https://github.com/sirkkalap/proxytunnel.git
cd proxytunnel
make proxytunnel
#!/bin/sh
# curl -sSL https://gist.githubusercontent.com/sirkkalap/f31998c57cc0c3b5fbd5b0b0ee7bbca2/raw/3665a4962caba46b2729e4b5b835503c98734ae2/git-lg.sh | sh -
git config --global alias.lg \
"log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative"
@sirkkalap
sirkkalap / brew_update_upgrade.sh
Created March 17, 2016 15:56
Keep up to date with Homebrew
#!/bin/sh
BASEDIR=$(cd $(dirname $0); /bin/pwd)
($BASEDIR/isodate && /usr/local/bin/brew update && /usr/local/bin/brew upgrade --all) >>$HOME/brew-update.log 2>&
@sirkkalap
sirkkalap / test-dns.sh
Last active March 16, 2016 11:27
Sometimes DNS answers change unexpectedly. This shell script will try to log DNS answers. You may change the DNS-server IP addresses on lines 4 and 5.
#!/bin/bash
while true; do
echo $(date +%FT%T%z) $(dig +noall +answer +stats ftp.example.com | tr '\n' ' ')
echo $(date +%FT%T%z) $(nslookup ftp.example.com 10.1.2.3 | tr '\n' ' ')
echo $(date +%FT%T%z) $(nslookup ftp.example.com 10.2.4.6 | tr '\n' ' ')
sleep 60
done
#[sirkkalap@mymachine ~]$ nohup ./test_dns.sh &
#[1] 16406
#[sirkkalap@mymachine ~]$ tail nohup.out
@sirkkalap
sirkkalap / curl-times.sh
Last active March 11, 2016 12:59
Take response times of a site at given interval
#!/bin/bash
# Adopted from https://josephscott.org/archives/2011/10/timing-details-with-curl/
#
url=${1:?usage "[nohup] curl-times.sh <url> [ <sleep=1> ]"}
sleep=${2:-1}
format=" time_namelookup: %{time_namelookup} time_connect: %{time_connect}, time_appconnect: %{time_appconnect}, time_pretransfer: %{time_pretransfer}, time_redirect: %{time_redirect}, time_starttransfer: %{time_starttransfer}, time_total: %{time_total}\n"
while true; do
echo -n $(date +%FT%T%z)
curl -w "${format}" -o /dev/null -s "$url"
@sirkkalap
sirkkalap / start-docker-sonar.sh
Created March 7, 2016 11:57
Start Sonar and Sonar MySQL database in one command
#!/bin/bash
SONAR_IMAGE=tpires/sonar #sonar:kirre
SONAR_MYSQL_IMAGE=tpires/sonar-mysql
# Start Sonar MySQL
if docker inspect smysql >/dev/null; then
if docker inspect --format="{{ .State.Running }}" smysql >/dev/null; then
echo "Sonar MySQL already running"
else
docker start smysql
fi
@sirkkalap
sirkkalap / test-bfg.sh
Last active March 3, 2016 16:32
A simple shell example to test bfg-repo-cleaner.
#!/bin/bash
set -e # Fail fast
# Clean up last run artifacts
rm -rf private-repository temporary-repository mirror-repository public-repository
## Create empty repository representing the private repository
mkdir private-repository
@sirkkalap
sirkkalap / me.sh
Last active February 24, 2016 12:06
Some comfort settings for me
#!/bin/sh
WORK=${$1:-proj}
require() {
command -v $1 >/dev/null 2>&1 || { echo >&2 "I require $1 but it's not installed. Installing."; sudo $2; }
}
# Determine OS platform
UNAME=$(uname | tr "[:upper:]" "[:lower:]")
@sirkkalap
sirkkalap / hipchat
Created January 28, 2016 09:36
Open the company HipChat without "Chrome chrome"
#!/bin/sh
# OS X
chrome=/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome
if [ -e $chrome ]; then
$chrome --app=https://company.hipchat.com/chat/lobby
else
echo $chrome is required but not found.
fi
@sirkkalap
sirkkalap / Find script base dir on most posix environments
Created January 25, 2016 18:56
BASEDIR allows running scripts without cd'ing into their folders first. With properly set basedir all local resources can be referenced without CWD being in the script folder.
#!/bin/sh
BASEDIR=$(cd "$(dirname "$0")"; pwd)
echo $BASEDIR