Skip to content

Instantly share code, notes, and snippets.

@pbowyer
pbowyer / RelDate.php
Created December 5, 2011 08:55 — forked from arnaud-lb/RelDate.php
4 lines relative date formatter with DateInterval and Symfony2 Translator
<?php
use Symfony\Component\Translation\TranslatorInterface;
function format(\DateTime $date, TranslatorInterface $translator)
{
$diff = date_create()->diff($date);
$seconds = $diff->days * 86400 + $diff->h * 3600 + $diff->i * 60 + $diff->s;
$format = $translator->transChoice('reldate', $seconds);
@pbowyer
pbowyer / gist:1485532
Created December 16, 2011 10:28 — forked from lazymanc/gist:1485516
api routing
# artist api
artist:
url: /artist/*
param: { module: artist, action: methodSwitch }
# info api
info:
url: /info/*
param: { module: info, action: methodSwitch }
@pbowyer
pbowyer / gist:1485534
Created December 16, 2011 10:29 — forked from lazymanc/gist:1485485
symfony 1.4 api action class
<?php
/**
* Extended action class for adding json rendering functionality.
*
* @author Phil Moorhouse <[email protected]>
* @package tlv4
* @subpackage api
*/
class tlApiActions extends sfActions
{
@pbowyer
pbowyer / gist:1485535
Created December 16, 2011 10:29 — forked from lazymanc/gist:1485490
basic symfony html5 layout
<!DOCTYPE html>
<html>
<head>
</head>
<body>
<?php echo $sf_content ?>
</body>
@pbowyer
pbowyer / gist:1485537
Created December 16, 2011 10:29 — forked from lazymanc/gist:1485493
debug template
<?php var_dump($data); ?>
@pbowyer
pbowyer / gist:1486179
Created December 16, 2011 14:12 — forked from lazymanc/gist:1486168
sfWebBrowser cached version
<?php
/**
* Extended version of sfWebBrowser to provide caching functionality
*/
class tlCachedBrowser extends sfWebBrowser
{
protected $cache_expiration = 86400; // 1 day default cache
/**
class ProjectConfiguration extends sfProjectConfiguration
{
public function configureDoctrine(Doctrine_Manager $manager)
{
require_once sfConfig::get('sf_lib_dir') . '/../lib/cache/gyDoctrineCacheApc.class.php';
$cacheDriver = new gyDoctrineCacheApc();
$cacheDriver->setNamespace(md5(sfConfig::get('sf_root_dir')));
$manager->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $cacheDriver);
<?php
//Deletes all CSS classes and id's, except for those listed in the array below
function custom_wp_nav_menu($var) {
return is_array($var) ? array_intersect($var, array(
//List of allowed menu classes
'current_page_item',
'current_page_parent',
'current_page_ancestor',
'first',
'last',
@pbowyer
pbowyer / GTiff_compression_benchmark.py
Last active November 1, 2015 09:17 — forked from kr-stn/GTiff_compression_benchmark.py
Benchmark filesize and read/ write times for various GeoTiff compression algorithms
__author__ = 'kersten.clauss'
"""Benchmark different GeoTiff compression algorithms.
Usage: GTiff_compression_benchmark.py some_geo.tif
Requires the GDAL tools to be present and executable from the command line of your system.
This script will take a GeoTiff as input and create copies with different compression algorithms from it.
It measures the filesize, compression and decompression times and returns them as a table.
$ = jQuery;
/*
* jQuery BBQ: Back Button & Query Library - v1.3pre - 8/26/2010
* http://benalman.com/projects/jquery-bbq-plugin/
*
* Copyright (c) 2010 "Cowboy" Ben Alman
* Dual licensed under the MIT and GPL licenses.
* http://benalman.com/about/license/
*/