Skip to content

Instantly share code, notes, and snippets.

View jdu's full-sized avatar

Jeff Uren jdu

  • Wellcome Trust
  • Gloucestershire
View GitHub Profile
@jdu
jdu / gist:3250573
Created August 3, 2012 19:17
Re-Seed all tables
EXEC sp_MSforeachtable "DBCC CHECKIDENT ( '?', RESEED, 0)"
@jdu
jdu / gist:3243962
Created August 3, 2012 03:05
Disable/Enable Foreign Key Constraints for DB migrations [SQL Server]
# Disable
EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"
# Enable
exec sp_msforeachtable @command1="print '?'", @command2="ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"
@jdu
jdu / gist:3211251
Created July 30, 2012 22:39
Returning a JSON result from MongoDB (CodeIgniter)
// connect
$m = new Mongo();
// select a database
$db = $m->shugah;
// select a collection (analogous to a relational database's table)
$collection = $db->entry_types;
// find everything in the collection
@jdu
jdu / gist:3210204
Created July 30, 2012 21:04
OSX Lion Install PEAR
# 1. Run the installer
cd /usr/lib/php
sudo php install-pear-nozlib.phar
### 2. Edit /etc/php.ini and find the line: ;include_path = ".:/php/includes" and change it to: ###
# If you don't have php.ini you should have php.ini.default run "sudo cp php.ini.default php.ini"
include_path = ".:/usr/lib/php/pear"
@jdu
jdu / gist:3209947
Created July 30, 2012 20:35
Basic MongoDB access using PECL Mongo classes
<?php
// connect
$m = new Mongo();
// select a database
$db = $m->comedy;
// select a collection (analogous to a relational database's table)
$collection = $db->cartoons;
@jdu
jdu / gist:3209902
Created July 30, 2012 20:30
MongoDB AutoLaunch on OSX Lion
# 1. Create a new file at /Library/LaunchDaemons/org.mongo.mongod.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>org.mongo.mongod</string>
<key>RunAtLoad</key>
<true/>