Skip to content

Instantly share code, notes, and snippets.

View ericclemmons's full-sized avatar
🏠
Working from home

Eric Clemmons ericclemmons

🏠
Working from home
View GitHub Profile
@ericclemmons
ericclemmons / GetMessages.php
Created March 15, 2010 20:54
Zend Framework FlashMessenger Helper
<?php
/**
* GetMessages
*
* @author Eric Clemmons (eric@smarterspam.com)
* @category Zend
* @package Zend_View
* @subpackage Helper
*
@ericclemmons
ericclemmons / update-datetime.sql
Created April 8, 2010 18:25
Update a table's responses' datetimes so that all records have occurred recently
-- @last = the very last response
SELECT @last:=UNIX_TIMESTAMP(response_date) FROM responses GROUP BY response_date DESC LIMIT 1;
-- @diff = how much time has passed since the last response
SELECT @diff:=(UNIX_TIMESTAMP() - @last);
-- Add the date difference to all responses to chronologically bring them up to date
UPDATE responses SET response_date=FROM_UNIXTIME(UNIX_TIMESTAMP(response_date) + @diff);
@ericclemmons
ericclemmons / zend_wtform.php
Created May 17, 2010 21:37
This is how easy Zend_Form->persistDate() is
public function persistData($namespace = 'My_Super_Awesome_Form')
{
if (null === $this->_session) {
$this->_session = new Zend_Session_Namespace($namespace);
}
if ($this->_session->values) {
$this->populate($this->_session->values);
}
@ericclemmons
ericclemmons / My_Log_Writer_Backlog.php
Created July 7, 2010 20:29
Have Zend_Log_Writer_Mail send you entire error backlog
<?php
class Forms_Log_Writer_Backlog extends \Zend_Log_Writer_Mail
{
/**
* Array of all events sent to writer, unfiltered.
*
* @var array
*/
@ericclemmons
ericclemmons / theme.css
Created September 19, 2010 02:23
jQTouch Default theme modified with -moz rules
body {
background: #000;
color: #ddd;
}
#jqt a > img {
border: none;
}
div#jqt > * {
@ericclemmons
ericclemmons / default.phtml
Created October 21, 2010 04:45
Jekyll template
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>{{ page.title }} &mdash; CollegeDegrees.com</title>
</head>
<body>
{{ content }}
@ericclemmons
ericclemmons / bump_version
Created November 1, 2010 01:05
Bash script to merge, tag, & push the "develop" branch
#!/usr/bin/env bash
echo "Checking out master branch"
git checkout master
git pull origin master
git log master..develop
read -p "Review your changes..."
echo "Merging develop branch"
@ericclemmons
ericclemmons / My_Application_Resource_DoctrineODM.php
Created December 2, 2010 19:42
How to boostrap Doctrine2 ODM (similar with ORM) in Zend Framework
<?php
// Assumes you've installed via PEAR doctrine-common & doctrine orm/odm
use Doctrine\Common\ClassLoader,
Doctrine\Common\Annotations\AnnotationReader,
Doctrine\ODM\MongoDB\DocumentManager,
Doctrine\ODM\MongoDB\Mongo,
Doctrine\ODM\MongoDB\Configuration,
Doctrine\ODM\MongoDB\Mapping\Driver\AnnotationDriver;
@ericclemmons
ericclemmons / hackernews.de-pagify.js
Created March 7, 2011 01:32
Example recipe for adding "infinite scroll" to Hackernews
// README: https://github.com/ericclemmons/de-pagify
//
// Step 0 - Visit http://news.ycombinator.com/
// Step 1 - Inject jQuery (http://www.learningjquery.com/2009/04/better-stronger-safer-jquerify-bookmarklet)
// Step 2 - Inject De-Pagify (https://github.com/ericclemmons/de-pagify/raw/master/bookmarklet.jquery.min.js)
// Step 3 - Run the following in the console:
jQuery('td > table:eq(1)').depagify('td.title:last a', {
filter: 'tr',
threshold: 'td.title:last a',
@ericclemmons
ericclemmons / app.php
Created March 25, 2011 03:49
Zend-friendly app.php using APPLICATION_ENV
<?php
// This is the revised `web/app.php` (click the previous edit of this gist to see the original)
//
// For those of us that deploy along-side Zend Framework apps, whose convention has been to pivot configuration
// around APPLICATION_ENV, `web/app.php` and `web/app_dev.php` is redundant.
require_once __DIR__.'/../app/bootstrap.php.cache';
require_once __DIR__.'/../app/AppKernel.php';
//require_once __DIR__.'/../app/bootstrap_cache.php.cache';