Skip to content

Instantly share code, notes, and snippets.

View jimbojsb's full-sized avatar

Josh Butts jimbojsb

View GitHub Profile
<?php
public function getActionText()
{
session_start();
if($this->coupon_image) {
$action = 'view coupon';
} else if($this->in_store) {
if($this->product_deal) {
$action = 'get deal';
@jimbojsb
jimbojsb / gist:5df104147704c1d96302
Last active August 29, 2015 14:09
Mysql has gone away
public function processJob($job)
{
try {
// stuff
} catch(Exception $e) {
if(Offers\Model::getDb()->errno() == 2006) {
Offers\Model::connectDb();
$this->processJob($job);
} else {
throw $e;
@jimbojsb
jimbojsb / tweet.html
Last active August 29, 2015 14:17
Wes Finder - Javascript Exercise
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.4/js/bootstrap.min.js"></script>
<!-- fill in javascript as necessary -->
<!-- make the characters used counter live-updating as you type -->
<!-- if the user tries to submit the form with more than 140 characters, display a useful error message -->
<script type="text/javascript">
<?php
// coercive types, as per PersonFactory author's specification
class ElePHPant {
public $name, $age, $cuteness, $evil;
public function __construct(~string $name, ~int $age, ~float $cuteness, ~bool $evil) {
$this->name = $name;
$this->age = $age;
$this->cuteness = $cuteness;
$this->evil = $evil;
@jimbojsb
jimbojsb / Bash script for remote PHP Debugging
Created February 11, 2010 01:53
Simple Bash script to enable remote debugging of PHP Scripts in Eclipse
#!/bin/bash
QUERY_STRING="start_debug=1&debug_host=127.0.0.1&debug_port=10137"
CMD_ARGS = "$@"
$QUERY_STRING $CMD_ARGS
---doctrine.php---
<?php
define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
// Ensure library/ is on include_path
set_include_path(implode(PATH_SEPARATOR, array(
realpath(APPLICATION_PATH . '/../library'),
get_include_path(),
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
PS1='[\u@\h \w\[\033[32m\]$(__git_ps1)\[\033[0m\]]$ '
@jimbojsb
jimbojsb / SwitchLayout.php
Created July 1, 2011 04:53
Module-specific layouts in Zend Framework
<?php
class Genoa_Controller_Plugin_SwitchLayout extends Zend_Controller_Plugin_Abstract
{
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request)
{
$module = $request->getModuleName();
$layoutName = $module;
$layoutPath = APPLICATION_PATH . "/modules/$module/views/layouts";
Zend_Layout::startMvc();
$layout = Zend_Layout::getMvcInstance();
@jimbojsb
jimbojsb / gist:1665191
Created January 23, 2012 19:48
Delete local / remote hotfix and RC branches
for i in $(git branch -a | grep "rc-"); do git push origin :${i#remotes/origin/}; done