Skip to content

Instantly share code, notes, and snippets.

Avatar

Josh Butts jimbojsb

View GitHub Profile
View gist:9776400
<?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';
View gist:5df104147704c1d96302
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 Aug 29, 2015
Wes Finder - Javascript Exercise
View tweet.html
<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">
View scalar-type-signatures.php
<?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 / crawl.php
Created Mar 24, 2015
Entertainment.com Crawler
View crawl.php
<?php
/**
{
"require": {
"symfony/dom-crawler": "2.*",
"symfony/css-selector": "2.*"
}
}
*/
@jimbojsb
jimbojsb / Bash script for remote PHP Debugging
Created Feb 11, 2010
Simple Bash script to enable remote debugging of PHP Scripts in Eclipse
View Bash script for remote PHP Debugging
#!/bin/bash
QUERY_STRING="start_debug=1&debug_host=127.0.0.1&debug_port=10137"
CMD_ARGS = "$@"
$QUERY_STRING $CMD_ARGS
View Doctrine CLI with ZF Bootstrapper
---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(),
View Zend Framework Doctrine Resource
[production]
phpSettings.display_startup_errors = 0
phpSettings.display_errors = 0
includePaths.library = APPLICATION_PATH "/../library"
View Git Bash Prompt
PS1='[\u@\h \w\[\033[32m\]$(__git_ps1)\[\033[0m\]]$ '
@jimbojsb
jimbojsb / SwitchLayout.php
Created Jul 1, 2011
Module-specific layouts in Zend Framework
View SwitchLayout.php
<?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();
You can’t perform that action at this time.