Skip to content

Instantly share code, notes, and snippets.

View christiaan's full-sized avatar

Christiaan Baartse christiaan

View GitHub Profile
### Keybase proof
I hereby claim:
* I am christiaan on github.
* I am christiaan (https://keybase.io/christiaan) on keybase.
* I have a public key whose fingerprint is EF6C C61C 8A45 47FB A836 468D AB7D 8826 53C3 BB7E
To claim this, I am signing this object:
<?php
t('<a class="close close-btn" href="#">&times;</a>
<p>There has been placed <strong>%d new</strong> content items since your last visit.</p>
<div class="alert-actions">
<a id="new_content_view" class="btn small" href="%s">View items</a> <a id="new_content_opt_out" class="btn small" href="#">Don\'t notify me again</a>
</div>',
$count,
$text->entities(rtrim($nav->getCollectionURL($page), '/')) . '/' . $model->timestamp()
)
@christiaan
christiaan / gist:968554
Created May 12, 2011 14:02
Hyphenation 20x speed increase fix
Index: hyphenation.php
===================================================================
@@ -23,13 +23,9 @@
// Convert patterns
function convert_patterns($patterns) {
- $patterns = mb_split(' ', $patterns);
- $new_patterns = array();
- for($i = 0; $i < count($patterns); $i++) {
- $value = $patterns[$i];
@christiaan
christiaan / textarea.html
Created March 24, 2011 08:16
Block element textarea
<!doctype html>
<html>
</head>
<style>
textarea {
width : 100%;
/* only allow resize vertically */
min-width : 100%;
max-width : 100%;
height: 100px;
<?php
class Object implements IteratorAggregate, ArrayAccess
{
private $getters = array();
private $setters = array();
private $values = array();
private $prototype = null;
private $prototype_values = array();
public function __get($name)
function bind(obj, func) {
if(func.constructor === String) {
func = obj[func];
}
if(!(func instanceof Function)) {
throw new TypeError("func should be a Function");
}
return function() {
return func.apply(obj, arguments);
};
// @author Christiaan Baartse <christiaan@baartse.nl>
function newObject(objectClass, args) {
for(var argParams = [], i = 0, len = args.length; i < len; i++) {
argParams.push("a["+i+"]");
}
return (new Function("c", "a",
"return new c("+argParams.join(",")+");"))(objectClass, args);
};
// Usage
<?php
/**
* A class that takes the pain out of the $_FILES array
* @author Christiaan Baartse <christiaan@baartse.nl>
* @copyright 2010 Christiaan Baartse
*/
class UploadedFiles extends ArrayObject
{
public function current() {
return $this->_normalize(parent::current());
/*
* JS Port of Pimple by Fabien Potencier http://github.com/fabpot/Pimple
*/
function Pimple() {}
Pimple.prototype = {
set : function(id, value, shared) {
if(value.constructor === Function) {
if(shared) {
value = this.asShared(value);