Skip to content

Instantly share code, notes, and snippets.

View ChrisWelsh-mis's full-sized avatar

Christopher Welsh ChrisWelsh-mis

View GitHub Profile
@ChrisWelsh-mis
ChrisWelsh-mis / show_git_branch
Created November 25, 2017 09:38
Ubuntu: Show your git branch name on your terminal
Add these lines in your ~/.bashrc file
# Show git branch name
force_color_prompt=yes
color_prompt=yes
parse_git_branch() {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/'
}
if [ "$color_prompt" = yes ]; then
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ '
@ChrisWelsh-mis
ChrisWelsh-mis / NGINX tips
Created November 5, 2017 16:17
NGINX tips
HTTP to HTTPS
return 301 https://$host$request_uri;
REDIRECT NON-WWW TO WWW:
if ( $host !~ ^www\. ) {
return 301 $scheme://www.$host$request_uri;
}
REDIRECT WWW TO NON-WWW
if ( $host ~ ^www\.(?<domain>.+)$ ) {
@ChrisWelsh-mis
ChrisWelsh-mis / AWS Cannot resolve hostname
Last active January 4, 2018 10:18
AWS AMI Sudo; Cannot resolve hostname
sudo echo "127.0.0.1 $(hostname)" >> /etc/hosts
Go the the VPC management console, select the VPC, click on Actions, select Edit DNS Hostnames and select Yes.
#!/bin/bash
## This EC2 instance will need to be in the 'jenkins-ci-server' IAM Role
# get latest updates
sudo yum update -y
# add Jenkins repo
sudo wget -O /etc/yum.repos.d/jenkins.repo https://pkg.jenkins.io/redhat-stable/jenkins.repo
# import key from Jenkins CI
sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io.key
@ChrisWelsh-mis
ChrisWelsh-mis / thinBackup_to_S3.sh
Last active June 14, 2021 09:20
Backup Jenkins thinBackup to S3
#!/bin/bash
# lock script to prevent parallel running
scriptname=$(basename "$0")
pidfile="/tmp/${scriptname}-lock.pid"
exec 200>"$pidfile"
flock -n 200 || exit 1
pid=$$
echo $pid 1>&200
@ChrisWelsh-mis
ChrisWelsh-mis / AWS Configure
Last active January 4, 2018 10:18
BASH - Check aws configure has been set
#!/bin/bash
# Check AWS credentials exist
if [[ $(aws configure list | grep "*") && $? -eq 0 ]]; then
:
else
echo "Please configure AWS credentials to continue..."
aws configure
fi
@ChrisWelsh-mis
ChrisWelsh-mis / 0_reuse_code.js
Created September 12, 2017 09:10
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console