Skip to content

Instantly share code, notes, and snippets.

View phptek's full-sized avatar

Russ Michell phptek

View GitHub Profile
@phptek
phptek / ss-upgrade.sh
Last active October 11, 2015 18:38 — forked from stojg/ss-upgrade.sh
Search and replace for SS 3.0 upgrade [beta]
#!/bin/bash
#
# ss-upgrader.sh
#
# INTRODUCTION
#
# There are some threads on the SS forums that describe the techdocs for upgrading a 2.4 site to 3.x as being too technical. Mainly from content authors who
# also happen to be site maintainers - they are not coders.
# The aim of this script is to therefore to automate - in as much as this is possible in a user-configured, open-source software project - to help those new to
# SS3 upgrade from 2.x as smoothly as possible.
@phptek
phptek / gist:6278911
Created August 20, 2013 08:49
A list of websites and applications that are, or purport to be, "Open Ideas" repositories
* http://myopenideas.com/
* http://www.openideo.com
* http://www.iinspireus.com/how-it-works/sharing
* http://openideas.ideon.co
* http://en.wikipedia.org/wiki/Open_innovation
* http://www.whynot.net/
* http://www.globalideasbank.org/site/home/
Software:
@phptek
phptek / gist:7593542
Last active December 29, 2015 01:29
SVN to GIT project converter.
#!/usr/bin/env php -q
<?php
/*
* Modified from an original by Sam Minnee for SilverStripe Ltd
*/
if(empty($_SERVER['argv'][2])) {
echo "Usage: {$_SERVER['argv'][0]} <svn repo> <dest folder>\n";
echo "Runs: git svn clone for the repo and then manually pulls.\n";
exit(1);
@phptek
phptek / gist:fdcc7c53efedb2cd51fd
Last active August 29, 2015 14:02
BitBucket post-push hook
<?php
/**
*
* Receive POST requests from bitbucket.org and pull latest based on incoming branch filtering.
* Note: You'll need to setup www-data user (Debian) with SSH keys in the /var/www/.ssh dir and add the public key to bitbucket's UI.
*/
class bitbucketGit {
/**
*
@phptek
phptek / gist:f7128fa2da3c2d1b0dc1
Created March 24, 2015 19:43
Stupid SilverStripe project creation script
#!/bin/bash
#
# Create a new SilverStripe project in seconds.
# Russell Michell <russell@silverstripe.com>
#
# TODO
# 1). Add support for a greater range of composer executables
# 2). Add support for a greater range of webservers
# 3). Ping the repo to ensure it isn't down
@phptek
phptek / siege-ci.sh
Last active August 22, 2016 02:10
siege-ci.sh
#!/bin/bash
#
# Simple Siege wrapper for use in CI.
# A good use of this script might be in a CI setup calling a custom URL that featured many DB queries..
# Outputs 'PASS' or 'FAIL' to stdout/stderror respectively, for given URL(s) depending on:
#
# 1). Script params
# 2). Baked-in "acceptable" performance params (See "Performance Parameters" below)
#
# Russell Michell 2015 <russell.michell@deviate.net.nz>
@phptek
phptek / maxmem.sh
Last active August 29, 2015 14:18
Monitor RAM usage during a siege
#!/bin/bash
#
# Russell Michell 2015 <russell.michell@deviate.net.nz>
#
# Custom wrapper around /proc/meminfo designed to be invoked by something like `watch -n1 maxmem.sh`
# and run on a server under siege for RAM usage analysis. The script outputs used memory in Mb to a file which can
# be further analysed thus:
#
# cat outfile.out | sort -nr | head -1
#
@phptek
phptek / DIFMURLS
Created April 23, 2015 22:30
di.fm
http://listen.di.fm/public3/trance.pls
http://listen.di.fm/public3/vocaltrance.pls
/**
*
* Alternative and (will be) much faster menu generator to {@link ContentController::getMenu()}.
*
* - Uses raw DataQuery, skipping most of the ORM's heavy lifting
* - Doesn't require repeated calls to {@link Hierarchy::Children()}
* - Still works with unmodified template logic that calls $Menu(1).
SEE: Hierarchy::loadDescendantIDListInto()
*
* @param int $level Menu level to return.
/**
*
* In order to tell whether any Fluent-enabled (FLuent augmented) ORM queries
* exist on the current object and whether or not they have data, we need to
* hook into all ORM queries made on each page. The result of which can be cached
* somewhere and consumed accordingly.
*
* Note: Doesn't augment anything. We're using augmentSQL() as an "entry-point".
*
* @param SQLQuery $query