Skip to content

Instantly share code, notes, and snippets.

View edmondscommerce's full-sized avatar

Edmonds Commerce edmondscommerce

View GitHub Profile
#!/usr/bin/env python
# Try to determine how much RAM is currently being used per program.
# Note per _program_, not per process. So for example this script
# will report RAM used by all httpd process together. In detail it reports:
# sum(private RAM for program processes) + sum(Shared RAM for program processes)
# The shared RAM is problematic to calculate, and this script automatically
# selects the most accurate method available for your kernel.
# Licence: LGPLv2
@edmondscommerce
edmondscommerce / is_cloudflare_caching.bash
Created September 6, 2018 10:45
Quickly test if Cloudflare is caching a resource
#!/usr/bin/env bash
readonly DIR=$(dirname $(readlink -f "$0"))
cd $DIR;
set -e
set -u
set -o pipefail
standardIFS="$IFS"
IFS=$'\n\t'
@edmondscommerce
edmondscommerce / gulpfile.js
Last active January 19, 2018 12:21
Front End Magento 1 SCSS Compilation
//Dependencies
var gulp = require('gulp');
var browserSync = require('browser-sync');
var sass = require('gulp-sass');
var cleanCss = require('gulp-clean-css');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
var pump = require('pump');
var reload = browserSync.reload;
@edmondscommerce
edmondscommerce / .vimrc
Created October 25, 2017 10:18
Joseph's basic vimrc file
" =============== STANDARD VIMRC STUFF ================
if v:lang =~ "utf8$" || v:lang =~ "UTF-8$"
set fileencodings=ucs-bom,utf-8,latin1
endif
set nocompatible " Use Vim defaults (much better!)
set bs=indent,eol,start " allow backspacing over everything in insert mode
"set ai " always set autoindenting on
"set backup " keep a backup file
set viminfo='20,\"50 " read/write a .viminfo file, don't store more
@edmondscommerce
edmondscommerce / set strict types on PHP files.bash
Created August 29, 2017 10:12
A bash script to allow you to easily set any missing declare(strict_types) in PHP files
#!/usr/bin/env bash
echo "
Setting Strict Types If It's Missing
-------------------------------------
"
for f in $(grep -r -L 'strict_types' $projectRoot/src);
do
echo "Found file with no strict types:"
@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
@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 / 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 / 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 / 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"
}