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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / 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 / SortSelect.jquery.js
Created February 15, 2010 21:56
Sort a SELECT box's OPTIONs alphabetically
var SortSelect = function(select) {
var options = jQuery.makeArray(select.find('option'));
var sorted = options.sort(function(a, b) {
return (jQuery(a).text() > jQuery(b).text()) ? 1 : -1;
});
select.append(jQuery(sorted))
.attr('selectedIndex', 0);
};
@ericclemmons
ericclemmons / TastePreferences.Netflix.jquery.js
Created January 17, 2010 01:48
Replace "Need some examples?" with actual examples
/*
Author: Eric Clemmons
Library: jQuery 1.3.2
When visiting "http://www.netflix.com/TastePreferences?lnkctr=wnph_sc_tst", I found myself
Clicking each "Click for example" link to better select my preference.
So, this script simply replaces that link with the first THREE suggested movie images.
Just Copy-Paste into Firebug & Run!
*/