Skip to content

Instantly share code, notes, and snippets.

View edmondscommerce's full-sized avatar

Edmonds Commerce edmondscommerce

View GitHub Profile
@edmondscommerce
edmondscommerce / My BASH header for every script.bash
Last active February 20, 2018 16:36
Paste this to the top of your BASH scripts for a much nicer BASH coding experience
#!/usr/bin/env bash
readonly DIR=$(dirname $(readlink -f "$0"))
cd $DIR;
set -e
set -u
set -o pipefail
standardIFS="$IFS"
IFS=$'\n\t'
echo "
===========================================
@edmondscommerce
edmondscommerce / Bash script to change wallpaper on Fedora
Created June 22, 2016 13:03
Bash script to change wallpaper on Fedora - Ideal to be run on a cron basis
#!/usr/bin/env bash
PID=$(pgrep -n gnome-session)
export DBUS_SESSION_BUS_ADDRESS=$(grep -z DBUS_SESSION_BUS_ADDRESS /proc/$PID/environ|cut -d= -f2-)
GSETTINGS_BACKEND=dconf
gsettings set org.gnome.desktop.background picture-uri '"file://'$(ls ~/Pictures/Wallpapers/*.jpg | shuf -n 1)'"'
@edmondscommerce
edmondscommerce / Get Column Numbers for CSV file in Bash.bash
Created January 12, 2017 18:02
Get Column Numbers for CSV file in Bash
# This will take a CSV file as input,
# pull out the header row,
# split that onto new lines
# and then prepend a zero indexed line number to each line
head ./filename.csv -n 1 | sed "s/,/\n/g" | awk '{printf("%d %s\n", NR-1, $0)}'
@edmondscommerce
edmondscommerce / JBidwatcher altnerative launcher file.sh
Created January 17, 2017 09:50
JBidwatcher alternative launcher file - can be run from any path, uses bash
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
cd $DIR
if (java -version 2>&1 | head -1 | fgrep -q "1.8")
then
java -cp lib/annotations.jar:lib/aopalliance.jar:lib/appbundler-1.0ea.jar:lib/apple.jar:lib/derby.jar:lib/guice-3.0.jar:lib/guice-assistedinject-3.0.jar:lib/jDeskMetrics.jar:lib/javax.inject.jar:lib/jdesktop.jar:lib/jl1.0.1.jar:lib/jline-2.11.jar:lib/jruby-incomplete.jar:lib/json_simple-1.1.jar:lib/jsoup-1.7.1.jar:lib/jsr305-1.3.9.jar:lib/l2fprod-common-fontchooser.jar:lib/mahalo.jar:lib/mysql-connector-java-5.1.7-bin.jar:lib/readline.jar:lib/txtmark.jar:lib/jbidwatcher:app/JBidwatcher.jar com.jbidwatcher.app.JBidWatch
else
echo "You must install Oracle's Java 8 to run JBidwatcher."
echo "Download it from here:\n\thttps://www.java.com/download"
@edmondscommerce
edmondscommerce / systemd-config-path.bash
Created June 8, 2017 11:37
Systemd quickly get config path for service
#!/usr/bin/env bash
function systemdConfigPath(){
service=$1
systemctl show $service --no-pager | grep FragmentPath= | cut -d '=' -f 2
}
@edmondscommerce
edmondscommerce / phpunit-only-using-xdebug-for-coverage.bash
Created June 8, 2017 11:50
PHPUnit bash snippet to only use Xdebug if running all tests, otherwsise use a custom php.ini that has xdebug disabled
#!/usr/bin/env bash
phpCmd="/usr/bin/php"
function phpNoXdebug {
local temporaryPath="$(mktemp -t php.XXXX).ini"
# Using awk to ensure that files ending without newlines do not lead to configuration error
/usr/bin/php -i | grep "\.ini" | grep -o -e '\(/[a-z0-9._-]\+\)\+\.ini' | grep -v xdebug | xargs awk 'FNR==1{print ""}1' > "$temporaryPath"
/usr/bin/php -n -c "$temporaryPath" "$@"
rm -f "$temporaryPath"
}
@edmondscommerce
edmondscommerce / laravel_static_analysis.bash
Last active August 20, 2021 08:23
Laravel PHPStan Runner
#!/usr/bin/env bash
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
cd $DIR;
set -e
set -u
set -o pipefail
standardIFS="$IFS"
IFS=$'\n\t'
echo "
===========================================
@edmondscommerce
edmondscommerce / php_upgrade.bash
Last active January 22, 2018 12:43
BASH Script to Upgrade PHP Version (From 7.0 to 7.1)
#!/usr/bin/env bash
# Assumes pacakages are from webtatic, might need to adjust for other repos
# @webtatic packages look like this:
# php71w-common.x86_64 7.1.7-1.w7 @webtatic
versionFrom=70
versionTo=71
yum list installed | grep php | grep $versionFrom > /tmp/php_installed
@edmondscommerce
edmondscommerce / img_optimiser.bash
Last active November 23, 2017 16:19
Magento Image Optimisation Script
#!/usr/bin/env bash
readonly DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
cd $DIR;
set -e
set -u
set -o pipefail
standardIFS="$IFS"
IFS=$'\n\t'
# To use this script you'll need to install:
@edmondscommerce
edmondscommerce / composer install slow internet connection.bash
Created August 23, 2017 08:17
Stop Composer timing out when using a slow internet connection
#!/usr/bin/env bash
COMPOSER_PROCESS_TIMEOUT=0 composer install