Skip to content

Instantly share code, notes, and snippets.

View Hallian's full-sized avatar

Nikolas Lahtinen Hallian

View GitHub Profile
@Hallian
Hallian / spinner.sh
Created March 5, 2016 22:20
Print a spinner in bash
#!/usr/bin/env bash
# @author Nikolas Lahtinen <nikolas.lahtinen@gmail.com>
#
# Print a spinner in bash
# Use in a script:
# source ./spinner.sh
# let TIME=0
# while [[ "$TIME" != "10" ]]; do
# echo -ne "\r" # Reset to beginning of the line
# spinner # Print spinner
@Hallian
Hallian / merge-json.sh
Created March 5, 2016 22:06
Merge json files with jq-1.5
#!/usr/bin/env bash
# @author Nikolas Lahtinen <nikolas.lahtinen@gmail.com>
#
# Merge json files with jq-1.5
# Usage:
# ./merge-json.sh *.json
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/auto-jq.sh # https://gist.github.com/Hallian/a3f53d247a92f4ace621
@Hallian
Hallian / auto-jq.sh
Created March 5, 2016 21:32
Automaticly acquire jq-1.5 in a bash script.
#!/usr/bin/env bash
# @author Nikolas Lahtinen <nikolas.lahtinen@gmail.com>
#
# Check if Jq version 1.5 is installed, if not, download it.
# Use in a script:
# source ./auto-jq.sh
# echo '{"key": "value"}' | $JQ .[]
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
JQ="$DIR/jq"
@Hallian
Hallian / package.sh
Created February 5, 2016 22:41
Create a .tar.gz package out of any files without copying stuff around into work folders. Use `tar` instead. It's made of magic.
#!/usr/bin/env bash
# @author Nikolas Lahtinen <nikolas.lahtinen@gmail.com>
# List the files you want to package between the lines that say "FILES"
read -r -d '' FILES << FILES
src
config
public
codedeploy/scripts
codedeploy/appspec.yml
@Hallian
Hallian / remote-backup-letsencrypt.sh
Created February 5, 2016 21:32
Backup letsencrypt from any server via ssh. Requires login user to have sudo privileges.
#!/usr/bin/env bash
if [[ -z $1 ]]; then
echo "Usage: ./remote-backup-letsencrypt.sh [user@host]"
exit 1
fi
ssh $1 "sudo tar -czf /tmp/letsencrypt.tar.gz /etc/letsencrypt"
scp -r $1:/tmp/letsencrypt.tar.gz .
ssh $1 "sudo rm /tmp/letsencrypt.tar.gz"
#!/usr/bin/env bash
# @author Nikolas Lahtinen <nikolas.lahtinen@gmail.com>
#
# Clones or pulls the repositories defined bellow.
# NOTE: Repository url must end in .git
read -r -d '' REPOSITORIES << REPOSITORIES
git@github.com:octocat/Hello-World.git
git@github.com:octocat/hello-worId.git
git@github.com:octocat/Spoon-Knife.git
@Hallian
Hallian / ueEug9AX
Created May 3, 2012 13:37 — forked from anonymous/ueEug9AX
a guest on May 3rd, 2012 - pastebin.com/ueEug9AX
/* Number of panels in total
Draw shadows for which panel (-1 for all) */
function draw_shadows(num, n) {
if (n != -1) num = n;
else n++;
for (n = n; n <= num; n++) {
alert(n);
}
}