Skip to content

Instantly share code, notes, and snippets.

View michaeltwofish's full-sized avatar

Michael C. Harris michaeltwofish

  • South Australia, Australia
View GitHub Profile
@michaeltwofish
michaeltwofish / gist:3958689
Created October 26, 2012 13:07
Slow query, extra field that the whole collection shares same value
> db.sittings.find({ "user.id" : "504fffe45c69233171000000", "status_id" : { "$in" : [ 1, 2 ] }, "app" : "schools", "metadata.client_id" : "4" }).explain()
{
"cursor" : "BtreeCursor user.id_1",
"nscanned" : 4,
"nscannedObjects" : 4,
"n" : 4,
"millis" : 686,
"nYields" : 0,
"nChunkSkips" : 0,
"isMultiKey" : false,
def fizzbuzz(number)
case
when number % 3 == 0 && number % 5 == 0
"Fizz, Buzz"
when number % 3 == 0
"Fizz"
when number % 5 == 0
"Buzz"
else
number.to_s
@michaeltwofish
michaeltwofish / mongoid.yml
Created June 6, 2012 05:42
mongoid configuration
development:
sessions:
default:
database: delivery_test
hosts:
- 127.0.0.1:27017
var req = https.request( options, function( res ) {
var data = '';
res.on('data', function( chunk ) {
data += chunk;
});
// Set the default connection based on the environment
Connections::add('default', array(
'development' => array(
'type' => 'MongoDb',
'host' => '127.0.0.1',
'database' => 'schools',
),
'test' => array(
'type' => 'MongoDb',
'host' => '10.10.20.4',
# cat /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux (EPEL)
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
@michaeltwofish
michaeltwofish / gist:2515912
Created April 28, 2012 04:30
Left join query
SELECT *, count(client_tests.id) AS test_count FROM clients LEFT JOIN client_tests ON clients.id = client_tests.client_id GROUP BY clients.id;
@michaeltwofish
michaeltwofish / gist:2410753
Created April 18, 2012 02:48
Lithium MongoDB unique tags from users
Get
array
'assertion' => string 'reduce -> multiple not supported yet' (length=36)
'assertionCode' => int 10075
'errmsg' => string 'db assertion failure' (length=20)
'ok' => float 0
From
@michaeltwofish
michaeltwofish / gist:2144979
Created March 21, 2012 05:52
Adding jquery to a theme
<head>
<title><?php Options::out( 'title' ); ?></title>
<meta charset="utf-8" />
<meta name="generator" content="Habari">
<!--[if IE]>
<script src="<?php Site::out_url( 'theme' ); ?>/html5.js"></script>
<![endif]-->
<?php Stack::add('template_header_javascript', Site::get_url('scripts') . '/jquery.js', 'jquery');?>
Warning: SimpleXMLElement::__construct(): Entity: line 3: parser error : Extra content at the end of the document in user/plugins/tests/tests.plugin.php line 64
user/plugins/tests/tests.plugin.php line 64:
SimpleXMLElement->__construct( …1 arg… )
[core] line 0:
TestsPlugin->action_admin_theme_get_tests( …1 args… )
system/classes/plugins.php line 80:
call_user_func_array( …1 args… )
system/handlers/adminhandler.php line 143:
Plugins::act( …1 args… )
system/handlers/actionhandler.php line 68: