Skip to content

Instantly share code, notes, and snippets.

View hejrobin's full-sized avatar
👠

Robin Grass hejrobin

👠
View GitHub Profile
@hejrobin
hejrobin / gist:921737
Created April 15, 2011 13:56
Demo of some of some routes in Architect
<routes>
<defaultController>Default</defaultController>
<!-- A simple custom route -->
<route path="about-us">
<controller callback="aboutUsPage">Company</controller>
</route>
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
class InternalStore {
protected $store;
public function __construct($store = array()) {
$this->setStore($store);
@hejrobin
hejrobin / gist:1117967
Created August 1, 2011 11:22
Architect Localization Usage
<?php
// English
$arch->locale->setLocale('en-US');
// Default english dict (en-US.xml)
echo $arch->lang->get('hello_world'); // Hello World
// Bork, english dict (en-US.xml) + translator module
$arch->locale->setTranslator('Enchefenizer');
echo $arch->lang->get('hello_world'); // Hellu Vurld
// I moustache you a question, but I'll shave it for later...
String.prototype.moustache = function(object, regex) {
return this.replace(regex || (/\\?\{\{([^{}]+)\}\}/g), function(match, key) {
if(match.charAt(0) == '\\')
return match.slice(1);
return (object[key] !== null) ? object[key] : '';
});
};
<?php
class UploadrException extends Exception {}
class Uploadr {
public $upload_path;
protected $max_file_size;
public $max_file_count = 0;
<?php
//ini_set('display_errors', 'On');
//error_reporting(E_ALL);
class Stylesheet {
private $css_rule_regex = '/(?ims)([a-z0-9\s\.\:#_\-@]+)\{([^\}]*)\}/';
public function __construct($css_data) {
$this->unparsed = $css_data;
@hejrobin
hejrobin / gist:1185991
Created September 1, 2011 11:28
Lexer usage
var lex = new Lingo.Lexer();
lex.setLexicon('foo', new Lingo.Dictionary({
name: 'Rövarspråket',
description: 'Rövarspråket',
lexicon: {
characters: {
'B': 'Bob', 'b': 'bob',
'C': 'Coc', 'c': 'coc',
'D': 'Dod', 'd': 'dod',
@hejrobin
hejrobin / gist:1185988
Created September 1, 2011 11:28
Awesome Javascript Lexer-thingy
(function() {
var Lingo = this.Lingo = {};
Lingo.Dictionary = function(dictionary) {
this.setDictionary(dictionary);
};
(function() {
this.log = function() {
// Really old browsers
if(typeof console == undefined)
var console = {};
// Just makin' sure...
if(typeof console.log == undefined)
console.log = function() {};
// Now we're talkin'
else if(typeof console == 'function') {
<?php
ini_set('display_errors', 'On');
error_reporting(E_ALL);
define('TYPEHINT_PCRE', '/^Argument (\d)+ passed to (?:(\w+)::)?(\w+)\(\) must be an instance of (\w+), (\w+) given/i');
class TypeHint {
private static $error_handler;