Skip to content

Instantly share code, notes, and snippets.

Avatar

Edmonds Commerce edmondscommerce

View GitHub Profile
View ps_mem.py
#!/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 Sep 6, 2018
Quickly test if Cloudflare is caching a resource
View is_cloudflare_caching.bash
#!/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 Jan 19, 2018
Front End Magento 1 SCSS Compilation
View gulpfile.js
//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 Oct 25, 2017
Joseph's basic vimrc file
View .vimrc
" =============== 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 Aug 29, 2017
A bash script to allow you to easily set any missing declare(strict_types) in PHP files
View set strict types on PHP files.bash
#!/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 Aug 23, 2017
Stop Composer timing out when using a slow internet connection
View composer install slow internet connection.bash
#!/usr/bin/env bash
COMPOSER_PROCESS_TIMEOUT=0 composer install
@edmondscommerce
edmondscommerce / img_optimiser.bash
Last active Nov 23, 2017
Magento Image Optimisation Script
View img_optimiser.bash
#!/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 Jan 22, 2018
BASH Script to Upgrade PHP Version (From 7.0 to 7.1)
View php_upgrade.bash
#!/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
View laravel_static_analysis.bash
#!/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 Jun 8, 2017
PHPUnit bash snippet to only use Xdebug if running all tests, otherwsise use a custom php.ini that has xdebug disabled
View phpunit-only-using-xdebug-for-coverage.bash
#!/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"
}