This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var DateHelper = { | |
// Takes the format of "Jan 15, 2007 15:45:00 GMT" and converts it to a relative time | |
// Ruby strftime: %b %d, %Y %H:%M:%S GMT | |
time_ago_in_words_with_parsing: function(from) { | |
var date = new Date; | |
date.setTime(Date.parse(from)); | |
return this.time_ago_in_words(date); | |
}, | |
time_ago_in_words: function(from) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class NamedArguments { | |
static function init($args) { | |
$assoc = reset($args); | |
if (is_array($assoc)) { | |
$diff = array_diff(array_keys($assoc), array_keys($args)); | |
if (empty($diff)) return $assoc; | |
trigger_error('Bad parameters: '.join(',',$diff), E_USER_ERROR); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class MyController extends Zend_Controller_Action { | |
public $contexts = array( | |
'request' => array('json', 'html') | |
); | |
public function requestAction() { | |
$this->view->fields = Foo::getFields(); | |
// Here i want to build the form - but ONLY if context is 'html' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wget -m -k -K -E <URL> # archive entire site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
if [ $# -eq 2 ]; then | |
email="$1" | |
password="$2" | |
curl -L -d "email=$email&password=$password" -c ontv.cookie 'http://ontv.dk/scripts/users.php?action=login' | |
xmltvurl=$(curl -b ontv.cookie 'http://ontv.dk/xmltv' | perl -ne '/(http:\/\/ontv.dk\/xmltv\/\w+)/ and print $1') | |
curl -o xmltv.xml "$xmltvurl" | |
rm ontv.cookie | |
exit 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
usage() { | |
echo >&2 "Usage: $0 [ -d directory | --dir directory ] [ -u user | --user user ] | --help" | |
} | |
invalid() { | |
echo >&2 "Invalid option $1. Try $0 --help to see available options." | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Thanks: http://snook.ca/archives/php/url-shortener | |
$codeset = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"; | |
$base = strlen($codeset); | |
$n = 300; | |
$converted = ""; | |
while ($n > 0) { | |
$converted = substr($codeset, ($n % $base), 1) . $converted; | |
$n = floor($n/$base); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$connection = new PDO($dsn); | |
// 1. | |
$persons = new Table($connection, 'persons'); | |
$joe = $table->createRow(array('name' => 'Joe')); | |
$persons->save($joe); | |
// 2. | |
$person = array( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git config gitex.exportbranch PHP5 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Helper_ActionCache extends Zend_Controller_Action_Helper_Abstract { | |
public function preDispatch() { | |
$this->fire('pre'); | |
} | |
public function postDispatch() { | |
$this->fire('post'); | |
} |
OlderNewer