Skip to content

Instantly share code, notes, and snippets.

View boutell's full-sized avatar

Tom Boutell boutell

View GitHub Profile
@boutell
boutell / mongoose-unique-index-error-test.js
Created April 14, 2012 15:15
Test: retrying save after a unique index error does not work
/**
* Create a situation where a unique index error will occur. Try to save the
* object again after making the relevant field unique. Expected behavior:
* object saves second (or third...) time and we wind up with ten objects. Actual behavior:
* we get just one object and there is a unique index error after all ten save callbacks
* have already been invoked "successfully"! This is really strange, even stranger than I
* thought. Maybe the index is not applied yet somehow and I need to wait on the schema
* being ready?
*
@boutell
boutell / profile.php
Created April 7, 2012 14:11
Profile CPU performance at 1-minute intervals, compare it to reported load average
<?php
$file = dirname(__FILE__) . '/profile.csv';
$out = fopen($file, 'a');
$load = @file_get_contents('/proc/loadavg');
$load = preg_split('/ /', $load);
$load = $load[0];
@boutell
boutell / gist:1811024
Created February 12, 2012 21:51
Executing the same query in MongoDB and MySQL
I'm going to examine a plausible, nontrivial query that comes up for client sites and
consider how it would be implemented in both MongoDB and a MySQL back end that attempts
to support a lot of the capabilities we like in MongoDB.
I'm not going to look at how we retrieve the inner contents of a page (nested contents)
or information about subpages (related contents) because I have a pretty good idea how
we want to cope with those bits in both cases.
The query syntax here is just pseudocode, I'm not proposing it:
@boutell
boutell / pages_yml_ideas.yml
Created January 24, 2012 20:06
Structuring information about page templates and their contents in Apostrophe (2?)
templates:
home:
areas:
header
body
footer
slots:
splash:
type: aImage
logo: