Skip to content

Instantly share code, notes, and snippets.

Table Of Contents
Acknowledgments.............................................................................i
An Introduction to The CodeIgniter Handbook ................................................ii
An Introduction to Volume One...............................................................iii
Who should read this book? .................................................................iv
Part 1 - Models
Fat Model, Skinny Controller........................................................... 3
Standard Model Conventions............................................................. 4
Observers ............................................................................. 16
@jamierumbelow
jamierumbelow / denormalized_models.rb
Created February 15, 2012 23:42
A concept for a denormalization plugin for Rails
class Forum < ActiveRecord::Base
has_many :topics
belongs_to :category, :denormalize => [ :name ]
end
class Topic < ActiveRecord::Base
belongs_to :forum
has_many :messages
denormalizes :messages, :as => :messages_count { messages.length }
@jamierumbelow
jamierumbelow / progress.css
Created January 25, 2012 16:10
Pretty CSS progress bars
.progress { height: 15px; max-width: 300px; background: #555; position: relative; -moz-border-radius: 25px; -webkit-border-radius: 25px; border-radius: 25px; -webkit-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3); -moz-box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3); box-shadow: inset 0 -1px 1px rgba(255,255,255,0.3); }
.progress > span {
display: block;
height: 100%;
-webkit-border-top-right-radius: 8px;
-webkit-border-bottom-right-radius: 8px;
-moz-border-radius-topright: 8px;
-moz-border-radius-bottomright: 8px;
border-top-right-radius: 8px;
@jamierumbelow
jamierumbelow / currencies.json
Created January 5, 2012 11:34
A simple currency helper for PHP. Includes clever display and currency conversion.
{
"aed": {
"priority": 100,
"iso_code": "AED",
"name": "United Arab Emirates Dirham",
"symbol": "د.إ",
"subunit": "Fils",
"subunit_to_unit": 100,
"symbol_first": true,
"html_entity": "",
@jamierumbelow
jamierumbelow / gist:1559658
Created January 4, 2012 11:30
How to remove all traces of Michael Bublé from Spotify.
var sp = getSpotifyApi(1),
models = sp.require('sp://import/scripts/api/models'),
player = models.player;
exports.init = function(){
player.observe(models.EVENT.CHANGE, function(e){
if (e.data.curtrack == true) {
if (player.track.album.artist.name == 'Michael Bublé') {
player.play('spotify:track:5xMAMaVbW3tkjXTmSUBPTd');
}
@jamierumbelow
jamierumbelow / customer.php
Created October 1, 2011 09:55
A simple concept for basic JOIN/relationship support in MY_Model
<?php
class Customer extends MY_Model {
protected $relations = array(
'addresses' => array(
'join_on' => 'addressable_id',
'where' => array('addresses.addressable_type' => 'customers')
)
);
}
The Comedian
by Jamie Rumbelow
-----------------
Sometimes I, I despise being me, being unhappy
Because no, nobody ever takes me seriously
Still I try to be wise and laugh when others laugh at me
Look around, see what you’ve done, I’m Cassius, I’ve killed everyone,
Every day in your needled way, can you stop? Are you done?
@jamierumbelow
jamierumbelow / original.php
Created May 16, 2011 22:52
A potential, CoffeeScript-esque nicer PHP
// ----------------------
// NO <?php TAG!
// ----------------------
// ----------------------
// SIGNIFICANT WHITESPACE ELIMINATES THE NEED
// FOR CURLY BRACES (YAY)
// ----------------------
class Sessions extends MY_Controller
cd ~/Sites
export EDITOR="mate "
PS1="\[\033[1;44m\]\n\u:\w \$(vcprompt)\n\[\033[0m\] "
export RAILS_ENV="development"
export PATH="/usr/local/Cellar/php/5.3.6/bin:/Users/jamierumbelow/local/node/bin:/Users/jamierumbelow/pear/bin/:/usr/local/apache2/bin/:$PATH"
if [ -f `brew --prefix`/etc/bash_completion ]; then
@jamierumbelow
jamierumbelow / gist:967113
Created May 11, 2011 19:24
Sweetie, you're going to forget me
Sweetie, you're going to forget me
by Jamie Rumbelow
==============================
Capo on 3, but the chords are NOT relative
Abmaj7 (played like an open F), Ebmaj7
Sweetie, that day that you left me,
I knew you were gonna forget me
Sweetie, know that you upset me,