Skip to content

Instantly share code, notes, and snippets.

View kbjr's full-sized avatar

James Brumond kbjr

View GitHub Profile
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Const_class {
protected static $data = array();
public function __construct()
{
self::$data = array(
// Any initial data
@kbjr
kbjr / gist:506185
Created August 3, 2010 11:01
An example of using my OpenID library with CodeIgniter (http://github.com/kbjr/EasyOpenID)
<?php
//...
function try_auth()
{
// load the library
$this->load->library('EasyOpenID');
// start the request
@kbjr
kbjr / gist:657436
Created November 1, 2010 01:25
I can't believe I actually just put this in a piece of code...
else
{
// This should never happen, but you can put
// something here if you really want to...
die('Woah... How did that happen...?');
}
@kbjr
kbjr / callstack.js
Created April 3, 2011 04:00
A convenient way of stacking up functions
/*
|------------------------------------------------
| CallStack
|------------------------------------------------
|
| A convenient way of stacking up functions
|
| @author James Brumond
| @copyright Copyright 2011 James Brumond
| @license Dual licensed under MIT and GPL
@kbjr
kbjr / gist:900217
Created April 3, 2011 05:24
YourBrowserFailsError
// For those cases when there just isn't any other explanation...
if (typeof window.YourBrowserFailsError === 'undefined') {
window.YourBrowserFailsError = function(msg) {
// Make sure it is called with "new"
if (! this instanceof YourBrowserFailsError) {
return new YourBrowserFailsError(msg);
}
// Get an actual error object for the stack
var err = (function() {
var err;
@kbjr
kbjr / LICENSE.txt
Created June 14, 2011 09:31 — forked from sebastien-p/LICENSE.txt
JavaScript implementation of the Lempel–Ziv–Welch universal lossless data compression algorithm.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
Version 2, December 2004
Copyright (C) 2011 Sebastien P. https://twitter.com/#!/_sebastienp
Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
@kbjr
kbjr / pcre-xregexp.js
Created November 1, 2011 07:24
XRegExp modified for phpjs pcre functions
//
// A modified, extended version of XRegExp meant to be easily implemented
// in PCRE style regular expression functions.
//
var pcreXRegExp = (function() {
var _XRegExp;
var pcreXRegExp = function(pattern) {
var del = pattern.charAt(0);
var lastIndex = pattern.lastIndexOf(del);
var fpattern = pattern.substring(1, lastIndex);
@kbjr
kbjr / gist:3887079
Created October 14, 2012 02:47
Models
Pak {
id: String,
name: String,
description: String,
pages: [ Page ]
}
Page {
id: String,
title: String,
@kbjr
kbjr / gist:3995804
Created November 1, 2012 19:16
Assessment Attempt Model
Attempt {
finished: Boolean,
score: Number,
answers: [{
question: Question,
answer: [Answer],
score: Number
}]
}
@kbjr
kbjr / gist:3995805
Created November 1, 2012 19:16
Assessment Attempt Model
Attempt {
finished: Boolean,
score: Number,
answers: [{
question: Question,
answer: [Answer],
score: Number
}]
}