Skip to content

Instantly share code, notes, and snippets.

View jbrooksuk's full-sized avatar
🧑‍🚀

James Brooks jbrooksuk

🧑‍🚀
View GitHub Profile
@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: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 / bugfy.pushover.php
Created August 14, 2012 09:53
Bugify External Hook URL - Pushover
<?php
/**
* Bugify External Hook URL with Pushover.
* @author James Brooks <[email protected]>
*/
if(!isset($_POST['payload'])) die('Error.');
// You don't need to change this bit.
@jbrooksuk
jbrooksuk / gist:2204090
Created March 26, 2012 09:14
PHP .properties class
<?php
/**
* Parses the build.properties used by Phing
* @author James <[email protected]>
*/
class Properties {
protected static $_instance = NULL;
public static $propFile = "";
@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: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 / 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:1006285
Created June 3, 2011 12:53
jQuery Plugin to reverse $.each
jQuery.fn.reverse = [].reverse;
@jbrooksuk
jbrooksuk / gist:1004154
Created June 2, 2011 09:16
Table rows/cols selection
<!DOCTYPE html>
<html>
<head>
<title>jQuery RTE Dynamic Table Insertion Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<style type="text/css">
.aBlock {
width: 20px;
height: 20px;
background-color: #A9EDF5;
@jbrooksuk
jbrooksuk / Sublime Text 2 PHP Build
Created April 12, 2011 08:34
Build file for PHP under Sublime Text Alpha 2
{
"cmd": ["php", "-l", "$file"],
"selector": "source.php",
"file_regex": "^Parse error: .* in (.*?) on line ([0-9]*)"
}