Skip to content

Instantly share code, notes, and snippets.

View michaeltwofish's full-sized avatar

Michael C. Harris michaeltwofish

  • South Australia, Australia
View GitHub Profile
[root@phoenix ~]# puppet agent --no-daemonize --verbose
notice: Starting Puppet client version 2.7.9
err: Could not retrieve catalog from remote server: certificate verify failed. This is often because the time is out of sync on the server or client
info: Not using expired catalog for phoenix from cache; expired at Tue Mar 13 19:26:10 +0000 2012
notice: Using cached catalog
err: Could not retrieve catalog; skipping run
err: Could not send report: certificate verify failed. This is often because the time is out of sync on the server or client
[epel]
name=Extra Packages for Enterprise Linux 5 - $basearch
#baseurl=http://download.fedoraproject.org/pub/epel/5/$basearch
mirrorlist=http://mirrors.fedoraproject.org/mirrorlist?repo=epel-5&arch=$basearch
failovermethod=priority
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL
[epel-debuginfo]
<?php
$input = 'some stuff <?= $this->foo ?> blah';
echo $input."\n";
echo preg_replace('/\<\?=\s*\$this->(.+?)\s*;?\s*\?>/msx', '<?php echo $this->$1; ?>', $input)."\n";
// Should output:
some stuff <?= $this->foo ?> blah
some stuff <?php echo $this->foo; ?> blah
?>
News::applyFilter('find', function($self, $params, $chain) {
$result = $chain->next($self, $params, $chain);
$function = function($item) {
$item->content = nl2br(htmlspecialchars($item->content, ENT_QUOTES, 'UTF-8'));
$item->date_updated_pretty_date = date('j F Y', strtotime($item->date_updated));
$item->date_updated_pretty_time = date('H:i', strtotime($item->date_updated));
$item->date_created = date('F jS, Y', strtotime($item->date_created));
$item->date_updated = date('F jS, Y', strtotime($item->date_updated));
$item->dealer_groups = explode(';', $item->dealer_groups);
@michaeltwofish
michaeltwofish / gist:1784787
Created February 10, 2012 00:30
Lithium MongoDB map reduce example
$map = 'function() {
this.forms.forEach(function(form){
form.clusters.forEach(function(cluster){
cluster.items.forEach(function(item){
emit(item, item);
})
})
})
}';
@michaeltwofish
michaeltwofish / gist:1777704
Created February 9, 2012 05:53 — forked from ringmaster/gist:1777673
Get all items from a test
db.tests.remove({slug: "foo"})
db.tests.insert({slug: "foo", forms: [ {slug: "section 1", clusters: [
{slug: "cluster 1", items: [1,2,3]},
{slug: "cluster 2", items: [4,5,6]}
]}]});
var map = function() {
this.forms.forEach(function(form){
form.clusters.forEach(function(cluster){
cluster.items.forEach(function(item){
$test = Test::create();
$form1 = new Form(array('name' => 'Form 1'));
$form2 = new Form(array('name' => 'Form 2'));
$form3 = new Form(array('name' => 'Form 3'));
$test->forms = array($form1,$form2,$form3);
$test->save();
@michaeltwofish
michaeltwofish / gist:1702154
Created January 30, 2012 02:45
Get the last PHP error
lasterror() {
logpath=/usr/local/www-conf/logs/$1-phplog;
error=(${(f)$(awk -F: '/PHP Fatal error|\[error\]/ { lines[last] = NR } END { print lines[last] }' $logpath)});
[[ -n $error ]] && tail -n +$error $logpath
}
static::applyFilter('find', function($self, $params, $chain) {
// Check if we're finding forms linked to a test
if (isset($params['options']['conditions']['test_id'])) {
$test_id = (int)$params['options']['conditions']['test_id'];
$params['options']['joins'] = array(new Query(array(
'source' => 'test_forms',
'constraint' => array ('Form.id' => 'test_forms.form_id', 'test_forms.test_id' => $test_id),
)));
unset($params['options']['conditions']['test_id']);
}
✘ test_cache_assets
Expected simple_assets key to exist in array ( )
test_pluggable.php:42
Expected simple_assets key to exist in array ( )
test_pluggable.php:42
Expected simple_assets key to exist in array ( )
test_pluggable.php:42