Skip to content

Instantly share code, notes, and snippets.

View PeloNZ's full-sized avatar

Chris Wharton PeloNZ

View GitHub Profile
@PeloNZ
PeloNZ / pre-commit.sh
Last active March 28, 2024 01:14
git hooks to run linter and coding standards in docker
#!/bin/sh
# before pushing code
# Run sniffer and fixer.
DOCKER_EXEC_COMMAND="docker exec --workdir /path/to/project container-name"
# Exclude warnings for now.
PHPCBF_COMMAND="vendor/bin/phpcbf --report=summary --standard=.phpcs.xml --warning-severity=0 --colors"
# Get a list of all files to be pushed
@PeloNZ
PeloNZ / git-submodule-sync.rb
Created January 19, 2016 11:18 — forked from frimik/git-submodule-sync.rb
Make damn sure that git submodule sync is going to work.
#! /usr/bin/env ruby
submods = Hash.new
%x{git config -f .gitmodules --get-regexp '^submodule\..*\.(path|url)$'}.lines.each do |l|
submodule, key, value = l.match(/^submodule\.(.*)\.(path|url)\s+(.*)$/)[1..3]
submods[submodule] = Hash.new unless submods[submodule].is_a?(Hash)
submods[submodule][key] = value
end
#!/bin/bash
# copy moodle database
set -x
set -e
if [ $1 ] ; then
DBFROM=$1
fi
if [ $2 ]; then
@PeloNZ
PeloNZ / deprecated-scan.sh
Last active August 29, 2015 14:22
scan for moodle deprecated functions
#!/bin/sh
# Scan for moodle deprecated functions in use
# Start from base directory
grep '^function' lib/deprecatedlib.php | cut -d ' ' -f 2 | cut -d '(' -f 1 | while read -r line ; do grep -rn "$line(" path/to/plugin ; done
@PeloNZ
PeloNZ / upgrade-setup.sh
Created May 22, 2015 14:22
quick db upgrade script
#!/bin/bash
set -x
if [ $1 ] ; then
DBFROM=$1
fi
if [ $2 ]; then
DBTO=$2
fi
@PeloNZ
PeloNZ / restore.sh
Last active August 29, 2015 14:19
restore postgres db dump
#!/bin/bash
set -x
set -e
if [ $1 ] ; then
DB=$1
fi
if [ $2 ]; then
FILE=$2
@PeloNZ
PeloNZ / example-local-setting.diff
Created February 13, 2015 17:00
example diff for making easy to manage customisations to moodle / totara core code
commit fbb65a025eacfc2842dc7a34d09b82c64d554041
Author: Chris Wharton <chris.wharton@catalyst-eu.net>
Date: Wed Dec 17 14:34:54 2014 +0000
local/client: Hide evidence tab from Record of Learning
diff --git a/lang/en/local_client.php b/lang/en/local_client.php
index 2dc6804..8dc1fa6 100644
--- a/lang/en/local_client.php
+++ b/lang/en/local_client.php
@PeloNZ
PeloNZ / moodle-theme-customcss
Created October 30, 2014 12:18
example for moodle & totara add custom css to theme settings page
commit 5472efadcbe6fb1b2e45fdd06c80fbf97254245b (HEAD, refs/heads/theme-2.5-custom-dev)
Author: Chris Wharton <chris.wharton@catalyst-eu.net>
Date: Thu Oct 30 12:08:53 2014 +0000
theme/custom: Add customcss setting
This is mainly for rapid fixes in between deployments.
diff --git a/config.php b/config.php
index 771b853..193a882 100644
@PeloNZ
PeloNZ / instructions
Created March 25, 2014 00:42
ssd caching setup for ubuntu
= ssd cache setup=
I got a new pc with an SSD and a spinner disk. Having to decide exactly what I think I needed on the SSD was hard. Why not try using it as a caching device?
==Why use ssd caching?==
* Intel's "Smart Response Technology" on Windows 7 is awesome
* SSD wear can be reduced
* The ssd use can be optimized automagically
* No compromise on free space on ssd vs empty space on hdd
===What runs slow normally for me?===
@PeloNZ
PeloNZ / kill-drop.sh
Created February 25, 2014 00:45
kill active postgres connections and drop the requested db
#!/bin/bash
# kill active pg connections and drop the requested db
DB=$1
psql -ec "SELECT pg_terminate_backend(pg_stat_activity.procpid) FROM pg_stat_activity WHERE pg_stat_activity.datname = '$DB' AND procpid <> pg_backend_pid();" postgres
dropdb $DB
exit 0;