Skip to content

Instantly share code, notes, and snippets.

View cspray's full-sized avatar

Charles Sprayberry cspray

View GitHub Profile
@cspray
cspray / windows-8-tablet-flawed.md
Created July 30, 2012 22:35
Microsoft's Windows 8 Strategy is Flawed

Windows 8 Tablet Strategy is Flawed

This is why I think Microsoft's tablet strategy with Windows 8, one OS to handle both mouse based and finger based input, is flawed and that Microsoft doesn't really "get" touch.

In case you've been kept out of the loop, Microsoft introduced a new keyboard and mouse that are designed to work well with tablets. Arguably the keyboard is a useful addition. Typing on a touch screen simply is not as efficient as the traditional physical keyboard. But the very need to create and market a mouse for a device designed to accept finger touch input is a sign of a flawed strategy.

You see, if you could perform your most basic tasks completely using touch then this isn't nearly that big a deal. But, [when Windows 8 dumps you into a desktop interface for various routine tasks](http://arstechnica.com/information-technology/2012/07/does-windows-8-succeed-as-a-true-tablet-operat

@cspray
cspray / else_if.md
Created July 27, 2012 22:37
Opcodes for else if versus elseif
<?php
if (false === true)
{}
else if (true === false)
{}
else
{}
?>
@cspray
cspray / gist:3190385
Created July 27, 2012 20:42
Say what...elseif versus else if
<?php
$start = microtime(true);
for($i = 0; $i < 10000000; $i++) {
if(2 === 0) {} else if(2 === 1) {} else {}
}
$end = microtime(true);
echo "else if: ".($end - $start)."<br />";
unset($start, $end);
$start = microtime(true);
@cspray
cspray / xdebug_ini_settings.php
Created May 14, 2012 14:04
Xdebug ini settings to show more info on var_dump
<?php
// Displays all array indices and object properties
ini_set('xdebug.var_display_max_children', -1);
// Displays all string data dumped
ini_set('xdebug.var_display_max_data', -1);
// Controls nested level displayed, maximum is 1023
ini_set('xdebug.var_display_max_depth', -1);
@cspray
cspray / gist:2629749
Created May 7, 2012 19:07
Outlook Rant

Recently I started working on a Windows based system and, by extension, Outlook. I'm not really a power email user and I can get by with just about any email client...as long as I can provide rules for emails so that my inbox isn't chock-full of crap. Fortunately, Outlook 2010 fully supports a wide variety of rules that should be able to handle just about any weird email routing you want. Overall, I really like the rule support provided by Outlook.

However, the support provided for group based rules is absolutely horrendous and the complete opposite of a good user experience. You see, Outlook has the ability to store and manage contacts...to include creating a group of contacts. You can email everybody in the group or setup a rule to route emails from the group to a specific folder. But, if you create a group-based rule Outlook throws up all over itself and says that the group must be converted into a list of individual contacts. The rub comes when you add, or remove, a contact from a group. The asso

@cspray
cspray / why-xml-sucks.md
Created May 2, 2012 15:18
Why we don't like XML

I was recently working with the FogBugz XML API and I needed to get some attribute value from the response. Below is the perfectly legal call chain needed to get an attribute value from my preferred XML parser, DOMDocument:

$case_id = $dom_document->getElementsByTagName('case')->item(0)->attributes->getNamedItem('ixBug')->nodeValue;

Assuming FogCreek chose to go with a JSON API for FogBugz we could expect something along these lines to get the same value:

$case_id = $json-&gt;case-&gt;ixBug
@cspray
cspray / gist:2040791
Created March 15, 2012 00:48
OOP storage benchmark omgz
<?php
error_reporting(-1);
class Tester {
protected $something;
public function __construct($something) {
$this->something = $something;
@cspray
cspray / gist:1833311
Created February 15, 2012 04:50
A snippet of code used to gather a SO Q&A that may be deleted soon
<?php
$questionUrl = 'https://api.stackexchange.com/2.0/questions/309300?page=1&pagesize=1&order=desc&sort=votes&site=stackoverflow&filter=!LP4hJGlAKQVCM-iPRmI8NA';
$curl = curl_init($questionUrl);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
$questionResponse = curl_exec($curl);
$answerUrl = 'https://api.stackexchange.com/2.0/answers/309622?order=desc&sort=activity&site=stackoverflow&filter=!akczUagg4t0rkU';
@cspray
cspray / gist:1822310
Created February 14, 2012 01:25
The code that generated the SO data for cspray.github.com/100-greatest-programming-books.html
<?php
$questionUrl = 'https://api.stackexchange.com/2.0/questions/1711/answers?site=stackoverflow&sort=votes&filter=withbody&page=1&pagesize=100';
$curl = curl_init($questionUrl);
curl_setopt($curl, CURLOPT_HTTPGET, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_ENCODING, 'gzip');
$response = curl_exec($curl);
$response = json_decode($response, true);