Skip to content

Instantly share code, notes, and snippets.

@gmcinnes
gmcinnes / gist:6769227
Created September 30, 2013 19:54
Javascript for pipe helper
<script type="text/javascript">
function iframeResizePipe()
{
// What's the page height?
var height = document.body.scrollHeight;
// Going to 'pipe' the data to the parent through the helpframe..
var pipe = document.getElementById('helpframe');
// Get our current location - staging? production? local?
var full = location.protocol+'//'+location.hostname+(location.port ? ':'+location.port: '');
// Cachebuster a precaution here to stop browser caching interfering
@gmcinnes
gmcinnes / gist:6132030
Last active December 20, 2015 12:38
Ideal world
[content]
h1. This is page title
p. This is a bunch of stuff
[/content]
[sidebar]
[box]
h1. Join Ent 101
p. Ent 101 is an awesome program!!!1
LULZ
[/box]
@gmcinnes
gmcinnes / rofo.rb
Last active December 19, 2015 21:48
message :body => /^\/(space)?rofo\s*([\d])*\s*$/ do
phrases = ["Subways, subways, subways!",
"Anything else?",
"I saved a billion dollars.",
"I'm running for mayor in 2014!",
"Gridlock creates pollution. It keeps you away from your families.",
"Cyclists are a pain in the ass.",
"The purpose of marathons is to create revenue for charities.",
"I stopped the Gravy Train!"
]
$result = $this->execute("SELECT * FROM wp_postmeta WHERE meta_key LIKE '_meta_box_id_application_date'");
if($result)
{
foreach($result as $row)
{
$type = gettype($row['meta_value']);
switch($type)
case 'string':
$date = date_from_string($row['meta_value']);
# backupninja
# /var/log/backupninja.log
#
$InputFileName /var/log/backupninja.log
$InputFileTag backupninja
$InputFileStateFile state_file_backupninja_backupninja
#$InputFileSeverity error
$InputFileFacility local7
$InputRunFileMonitor
$InputFilePollInterval 10
@gmcinnes
gmcinnes / core.rb
Last active December 16, 2015 12:49
Simplify?
module Model
module Core
include ExtensionLadder
end
end
@gmcinnes
gmcinnes / gist:5323709
Created April 6, 2013 00:33
Chef fail
[2013-04-06T00:02:53+00:00] INFO: Processing service[ssh] action restart (openssh::default line 30)
================================================================================
Error executing action `restart` on resource 'service[ssh]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
@gmcinnes
gmcinnes / data
Last active December 15, 2015 02:59
data
[{"x"=>197.4499969482422, "y"=>16.08600044250488, "z"=>-12.13399982452393, "time"=>7.210000038146973}, {"x"=>37.80799865722656, "y"=>11.27200031280518, "z"=>"-0.46299999952316284", "time"=>"0.61000001430511475"}, {"x"=>171.1219940185547, "y"=>40.88700103759766, "z"=>-9.312000274658203, "time"=>5.559999942779541}, {"x"=>187.906005859375, "y"=>27.00600051879883, "z"=>-11.13300037384033, "time"=>6.610000133514404}, {"x"=>185.8450012207031, "y"=>29.08600044250488, "z"=>-10.91300010681152, "time"=>6.480000019073486}, {"x"=>123.9349975585938, "y"=>45.37799835205078, "z"=>-4.625999927520752, "time"=>3.049999952316284}, {"x"=>206.8040008544922, "y"=>3.440999984741211, "z"=>-13.07800006866455, "time"=>7.789999961853027}, {"x"=>84.2020034790039, "y"=>29.66799926757812, "z"=>-2.028000116348267, "time"=>1.659999966621399}, {"x"=>197.6100006103516, "y"=>15.88599967956543, "z"=>-12.15100002288818, "time"=>7.21999979019165}, {"x"=>203.3970031738281, "y"=>8.260000228881836, "z"=>-12.73900032043457, "time"=>7.579999923706055}
@gmcinnes
gmcinnes / gist:4046721
Created November 9, 2012 16:35
composer.json
{
"name": "email-preferences-centre",
"description": "Your email preferences, all in one convenient cent-re",
"require": {
"silex/silex": "1.0.*",
"twig/twig": ">=1.8,<2.0",
"symfony/twig-bridge": "2.1.*",
"symfony/form": "2.1.*",
"symfony/templating": "2.1.*",
"symfony/security": "2.1.*",
resource_fieldname = field.keys.first
resource_field = @resource.send(resource_fieldname)
resource_field_value = field.values.first
target = resource_field[resource_field_value]
# This if you don't care what it becomes if it's not an array previously
#target = agent.id if target.is_a? Array
# This if you always want it to end up as an array, even if it wasn't previously
#target = agent.id rescue target = []
target.save