Skip to content

Instantly share code, notes, and snippets.

View elliotttf's full-sized avatar

Elliott Foster elliotttf

View GitHub Profile
<?php
function test($a) {
foreach ((array) $a as $k) {
echo $k . PHP_EOL;
}
// Ruh roh.
echo $a[0];
}
<s:simpleType name="HourType">
<s:restriction base="s:string">
<s:enumeration value="Unknown"/>
<s:enumeration value="TwelveAM"/>
<s:enumeration value="TwelveThirtyAM"/>
<s:enumeration value="OneAM"/>
<s:enumeration value="OneThirtyAM"/>
<s:enumeration value="TwoAM"/>
<s:enumeration value="TwoThirtyAM"/>
<s:enumeration value="ThreeAM"/>
@elliotttf
elliotttf / example.php
Created December 1, 2011 19:25
Example of adding files to solr document that are only linked to in the node body.
<?php
/**
* Implements hook_apachesolr_document_handlers().
*/
function example_apachesolr_document_handlers($type, $namespace) {
if ($type == 'node' && $namespace == 'example') {
return array('example_add_documents');
}
}
@elliotttf
elliotttf / comment.php
Created December 20, 2011 19:16
Transaction comment
<?php
// This is a bit hacky, but here's why: node_save is wrapped in a
// transaction which means that our keeper info won't be written
// to the database until after everything in node_save finishes.
// That would be fine except for the fact that we're asynchronously
// interacting with the PuSH hub. When the hub calls back to Drupal
// the keeper info still hasn't been written to the database.
// To avoid the problem this causes we're making subscription requests
// on node load. Lord have mercy on my soul.
@elliotttf
elliotttf / memory_leak.diff
Created January 6, 2012 19:59
Memory leak plugged
diff --git a/lib/pubhub.js b/lib/pubhub.js
index 1878e96..9d22ab8 100644
--- a/lib/pubhub.js
+++ b/lib/pubhub.js
@@ -152,6 +152,11 @@ PubHub.prototype.fetch = function(options) {
console.log('New data found on %s.', feedString);
self.emit('changed', data);
}
+
+ // Explicitly null out the data so it doesn't hang around after we're
@elliotttf
elliotttf / config
Created January 24, 2012 17:59
Ssh agent forwarding
Host *
ForwardAgent yes
<thing>
<date year="2011" month="8" date="4" day="4"/>
<time hour="22" minute="15" second="7" timezone="Eastern" utc-hour="-4" utc-minute="00"/>
<!-- ... -->
</thing>
var supportsOrientationChange = "onorientationchange" in window;
var orientationEvent = supportsOrientationChange ? "orientationchange" : "resize";
window.addEventListener(
orientationEvent, function() {
window.location.reload()
},
false
);
Order allow,deny
Allow from all
{
"name": "hosted-hubot",
"version": "2.1.4",
"author": "GitHub Inc.",
"keywords": "github hubot campfire bot",
"description": "A simple helpful Robot for your Company",
"licenses": [{
"type": "MIT",
"url": "http://github.com/github/hubot/raw/master/LICENSE"
}],