Skip to content

Instantly share code, notes, and snippets.

View andrewwheal's full-sized avatar

Andrew Wheal andrewwheal

  • Cognitran Ltd
  • Rugby, Warwickshire
  • 22:59 (UTC +01:00)
View GitHub Profile
@andrewwheal
andrewwheal / post-receive
Last active August 29, 2015 13:56
Git post-receive hook
if [ $(basename $(pwd)) == ".git" ]; then
cd ..
export GIT_DIR=.git
fi
git checkout $(git rev-parse master)
git reset --hard HEAD --
git submodule update --init --recursive
ant
@andrewwheal
andrewwheal / 001_db_stuff.php
Last active August 29, 2015 13:56
FuelPHP v1 Migration Examples/Suggestions
<?php
namespace Fuel\Migrations;
class Db_Stuff
{
public function up()
{
// Try/catch so that we can provide a nicer error message and gracefully fall out of the migration
@andrewwheal
andrewwheal / .gitconfig
Created October 15, 2013 16:52
Git word diff alias
wdiff = diff --color-words --word-diff-regex='[^[:space:]\\(\\)/<>{}\",_-]+'
@andrewwheal
andrewwheal / vhosts.conf
Last active December 25, 2015 12:19
Nginx vhost conf snippet for FuelPHP Example only, not guaranteed to work exactly as is.
server {
listen 80;
server_name example.com;
root /path/to/public;
location / {
try_files $uri /index.php?uri=$uri;
}
@andrewwheal
andrewwheal / fuel_app_config_config.php
Created October 2, 2013 14:42
FuelPHP always load log package
<?php
return array(
'always_load' => array(
'packages' => array(
'log',
),
$existing_item = $this->get_item_by_id($new_item->get_product_id());
if ($existing_item && $existing_item->bundle_variants && $new_item->bundle_variants) {
$fuck_you_1 = array_keys($existing_item->bundle_variants);
$fuck_you_2 = array_keys($new_item->bundle_variants);
sort($fuck_you_1); sort($fuck_you_2);
if ($fuck_you_1 != $fuck_you_2) {
$existing_item = null;
}
<?php
namespace DataGrid;
class DataGrid
{
/**
* Forge a new DataGrid
*
* @param string|\Fuel\Core\Database_Query_Builder_Select $table_or_query
@andrewwheal
andrewwheal / gist:6133131
Created August 1, 2013 16:47
Aliases file for use in IDEs with FuelPHP
<?php
class Autoloader extends \Fuel\Core\Autoloader {}
class Agent extends \Fuel\Core\Agent {}
class Arr extends \Fuel\Core\Arr {}
class Asset extends \Fuel\Core\Asset {}
class Asset_Instance extends \Fuel\Core\Asset_Instance {}
@andrewwheal
andrewwheal / .screenrc
Created May 13, 2013 08:41
A basic .screenrc config file
# Initial screens
screen -t eg 0 ssh user@host -t 'cd /file/path;bash'
screen -t ssh 9
# Hardstatus... duh
hardstatus on
hardstatus alwayslastline
hardstatus string '%{= kG}%{=kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%{g}'
# Autodetach session on hangup instead of terminating screen completely
@andrewwheal
andrewwheal / update_order.sql
Created April 12, 2013 14:15
Update a sequential int order field based on moving something with an ID to a specific position.
SET @id = 3;
SET @to = 9;
SET @lower = IF(@from < @to, @from, @to);
SET @upper = IF(@from < @to, @to, @from);
UPDATE `ordering`
SET `order` =
IF(`id` = @id,