Skip to content

Instantly share code, notes, and snippets.

View bshaffer's full-sized avatar

Brent Shaffer bshaffer

View GitHub Profile
public function getExportFilename()
{
return "<?php echo isset($this->config['export']['filename']) ? $this->config['export']['filename'] : ucfirst($this->getModuleName()).'_Export' ?>_".date("Y-m-d_Hi");
<?php unset($this->config['export']['filename']) ?>
}
<?php
class sfAdminRouteCollection extends sfDoctrineRouteCollection
{
protected function generateRoutes()
{
parent::generateRoutes();
if (!isset($this->options['with_export']) || $this->options['with_export'])
{
@bshaffer
bshaffer / gist:472862
Created July 12, 2010 18:28
Sample Crontab
[email protected]
# run daily crons
5 1 * * 1 /path/to/project/cron.php --daily > /var/log/cron_prod.log
10 1 * * 1 /path/to/other-project/cron.php --daily > /var/log/cron_dev.log
# run weekly crons
0 0 * * * /path/to/project/cron.php --weekly > /var/log/cron_prod.log
5 0 * * * /path/to/other-project/cron.php --weekly > /var/log/cron_dev.log
#!/usr/bin/php
<?php
if (!isset($argv) || !count($argv))
{
throw new Exception("Please provide path of crons to flush");
}
foreach ($argv as $path)
{
<?php
function link_to_current($title, $params = array(), $options = array())
{
$currentRoute = sfContext::getInstance()->getRouting()->getCurrentRouteName();
$currentParams = sfContext::getInstance()->getRequest()->getParameterHolder()->getAll();
unset($currentParams['module'], $currentParams['action']);
<div class="sf_admin_pagination">
<?php $img = image_tag(sfConfig::get('sf_admin_module_web_dir').'/images/first.png', array('alt' => __('First page', array(), 'sf_admin'), 'title' => __('First page', array(), 'sf_admin'))) ?>
<?php echo link_to_current($img, array('page' => 1)) ?>
<?php $img = image_tag(sfConfig::get('sf_admin_module_web_dir').'/images/previous.png', array('alt' => __('Previous page', array(), 'sf_admin'), 'title' => __('Previous page', array(), 'sf_admin'))) ?>
<?php echo link_to_current($img, array('page' => $pager->getPreviousPage())) ?>
<?php foreach ($pager->getLinks() as $page): ?>
<?php if ($page == $pager->getPage()): ?>
#!/usr/bin/env ruby
while line = STDIN.gets do
line.sub!(/\d,\"/) {|s| s.sub(',"', ' - ')}
line.sub!(/\d,/) {|s| s.sub(',', ' - ')}
line.gsub!('""', '"');
line.sub!(/"$/, '');
puts line
end
@bshaffer
bshaffer / Doctrine_Collection_Extra.class.php
Created July 20, 2010 18:15
order your result set by an array
<?php
/*
* Extended Doctrine Query class providing a few additional functions
* for wrapping your where clauses more efficiently
*/
class Doctrine_Query_Extra extends Doctrine_Query
{
public function addOrderBy($orderby, $values = null)
{
if ($values !== null)
<?php
function array_msort($array, $cols)
{
// clean cols
$cols = (array) $cols;
foreach ($cols as $col => $order) {
if (is_int($col)) {
// unassociative array.
$cols[$order] = SORT_ASC;
# redMine - project management software
# Copyright (C) 2006-2007 Jean-Philippe Lang
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of