Skip to content

Instantly share code, notes, and snippets.

View andrewwheal's full-sized avatar

Andrew Wheal andrewwheal

  • CloudCall Ltd
  • Rugby, Warwickshire
  • 16:11 (UTC +01:00)
View GitHub Profile
master o-o-o-o-o-A
A - original master
@andrewwheal
andrewwheal / modules-example-classes-controller-foo.php
Created December 17, 2012 15:06
Propeller Best Practices: Admin CRUD Controller and Views
<?php
namespace Example;
class Controller_Foo extends \Admin\Controller_Template
{
public function action_index()
{
$foo = Model_Foo::find('all');
* bb5a0c1 adding Feature D
|
* e43c9f0 (origin/minor, minor) bug-a merged into master; resolves #4
|\
| * 8f782bd fixing bug A
|/
* c2f9fe1 feature-c merged into master; resolves #3
|\
| * ca00ff6 doing some more stuff for feature C
| * 7fb4763 adding feature C
@andrewwheal
andrewwheal / convertNumToString.php
Created March 6, 2013 20:02
Function to convert a number to text
public static function convertNumToString($number, $limit = 999999999999) {
if (($number < 0) || ($number > $limit)) {
return $number;
}
if ($number == 0) {
return "zero";
}
$Tn = floor($number / 1000000000); /* Trillions (tera) */
@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,
@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 / 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 {}
<?php
namespace DataGrid;
class DataGrid
{
/**
* Forge a new DataGrid
*
* @param string|\Fuel\Core\Database_Query_Builder_Select $table_or_query
$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;
}
@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',
),