Skip to content

Instantly share code, notes, and snippets.

View PeloNZ's full-sized avatar

Chris Wharton PeloNZ

View GitHub Profile
@PeloNZ
PeloNZ / gist:5931194
Last active December 19, 2015 09:09 — forked from arnorhs/gist:1517095
#!/bin/bash
# This script will open all files from a git diff or a git show in vim.
# My bash skills are a bit primitive so this can probably be done more intelligently
# Usage:
# gitopen -- opens all added files that have changed since HEAD
# gitopen diff HEAD -- these are the default parameters
# gitopen diff master -- opens files that have changed from master
@PeloNZ
PeloNZ / ssl_check_function
Created September 10, 2013 03:43
useful function from wordpress to determine if a page is using ssl
/**
* Determine if SSL is used.
*
* @since 2.6.0
* @link http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/functions.php#L0
*
* @return bool True if SSL, false if not used.
* @license GPL
*/
public static function is_ssl() {
@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;
@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 / 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 / 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 / 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 / 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 / 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
#!/bin/bash
# copy moodle database
set -x
set -e
if [ $1 ] ; then
DBFROM=$1
fi
if [ $2 ]; then