Skip to content

Instantly share code, notes, and snippets.

View phptek's full-sized avatar

Russ Michell phptek

View GitHub Profile
@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 / 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
/**
*
* Determines if the current page has any translations.
*
* "Translation" means:
*
* >=1 of a page's translated fields e.g. `Title_ar_EG` is populated, And/Or
* >=1 of a page's `has|many_xxx` related classes, itself has >=1 translated + populated field(s), And/Or
* >=1 of a page's arbitrary ORM calls to a DataObject sub-class, itself has >=1 translated & populated field(s)
*
# PHPStorm Issues
## Environment
Ubuntu 14.04 / phpStorm 9.0.2 / OpenJDK 1.7.0_79 / Acer Aspire TimelineX
## Bugs
The IDE occassionally stalls such that I can no longer edit, or make any changes whatsoever to any
tabs that remain open. Neither can I move the caret around using up/down keys. If I switch to another project (in the same window) I cannot
@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.
Random notes from PHP Conf NZ 2015
* What core PHP functionality relies on SPL? (Core PHP5 interfaces for everyday use: http://php.net/manual/en/intro.spl.php)
* Take another look at Generators (Reduced memory footprint vs std iteration: http://php.net/manual/en/language.generators.overview.php)
* Look at File();
* Look at Pthreads proper multithreading
* What are co-routines again?
* ZTS Zend Thread Safety
* Performance:
- Measure TTFB