Skip to content

Instantly share code, notes, and snippets.

View jbrooksuk's full-sized avatar
🧑‍🚀

James Brooks jbrooksuk

🧑‍🚀
View GitHub Profile
@jbrooksuk
jbrooksuk / gist:1327855
Created October 31, 2011 16:12
PHP Switch in_array
<?php
$curURL = trim($_SERVER['REQUEST_URI'], '/');
$arURLParts = explode('/', $_SERVER['REQUEST_URI']);
foreach($arURLParts as $urlPart) {
${$urlPart} = $urlPart;
switch ($urlPart) {
case 'hotels':
$hotelPage = (($_GET['brand'] == "excellence") ? false : true);
break;
case 'country':
@jbrooksuk
jbrooksuk / gist:1336986
Created November 3, 2011 16:37
raise_array
<?php
function raise_array(array $arArray, $arKey) {
if(is_array($arArray[$arKey])) {
$arValues = $arArray[$arKey];
foreach($arValues as $aValue) {
$arArray[] = $aValue;
}
unset($arArray[$arKey]); // Remove key'ed value.
@jbrooksuk
jbrooksuk / calcPPrice.php
Created March 13, 2012 15:16
Calculates a percentage off of a price, then rounds to the next 9.
<?php
function calcPPrice($iPrice, $iDPrice = 1) {
$iDiscounted = round($iPrice - ($iPrice / 100 * $iDPrice));
return $iDiscounted - (10 - (9 - ($iDiscounted % 10)));
}
?>
@jbrooksuk
jbrooksuk / gist:2204090
Created March 26, 2012 09:14
PHP .properties class
<?php
/**
* Parses the build.properties used by Phing
* @author James <james@bluebaytravel.co.uk>
*/
class Properties {
protected static $_instance = NULL;
public static $propFile = "";
@jbrooksuk
jbrooksuk / bugfy.pushover.php
Created August 14, 2012 09:53
Bugify External Hook URL - Pushover
<?php
/**
* Bugify External Hook URL with Pushover.
* @author James Brooks <jbrooksuk@me.com>
*/
if(!isset($_POST['payload'])) die('Error.');
// You don't need to change this bit.
@jbrooksuk
jbrooksuk / gist:4007118
Created November 3, 2012 11:39
Windows Aero in AutoIt3
#include <GUIConstants.au3>
$Struct = DllStructCreate("int cxLeftWidth;int cxRightWidth;int cyTopHeight;int cyBottomHeight;")
$sStruct = DllStructCreate("dword;int;ptr;int")
Global $MyArea[4] = [50, 50, 50, 50]
$GUI = GUICreate("Windows Vista DWM", 243, 243)
$Apply = GUICtrlCreateButton("Apply", 80, 104, 83, 25, 0)
$ICE = GUICtrlCreateButton("DWM Check", 80, 134, 83, 25, 0)
@jbrooksuk
jbrooksuk / gist:4085787
Created November 16, 2012 09:18
JavaScript Proxy Pattern
(function() {
var proxied = window.alert;
window.alert = function() {
return proxied.apply(this, arguments);
};
})();
@jbrooksuk
jbrooksuk / gist:4130954
Created November 22, 2012 12:30
Sublime Text 2 Settings
{
"color_scheme": "Packages/Tomorrow Color Schemes/Tomorrow.tmTheme",
"draw_white_space": "selection",
"file_exclude_patterns":
[
".DS_Store",
".gitkeep",
".smb*"
],
"folder_exclude_patterns":
@jbrooksuk
jbrooksuk / .sublime-keymap
Created December 4, 2012 10:44
Sublime Text Insert Numbers
[
{ "keys": ["ctrl+alt+n"], "command": "prompt_insert_nums" }
]
@jbrooksuk
jbrooksuk / author.html
Created January 5, 2013 18:57
Extends Octopress by taking post variables over site defaults.
{% if post.author %}
{% assign author = post.author %}
{% elsif page.author %}
{% assign author = page.author %}
{% else %}
{% assign author = site.author %}
{% endif %}
{% capture googleplus_user %}{% if site.googleplus_user %}{{ site.googleplus_user }}{% endif %}{% endcapture %}