Skip to content

Instantly share code, notes, and snippets.

View jimbojsb's full-sized avatar

Josh Butts jimbojsb

View GitHub Profile
@jimbojsb
jimbojsb / gist:1878040
Created February 21, 2012 18:39
Turn on RDS Query Cache
rds-modify-db-parameter-group orca --parameters="name=query_cache_size, value=1073741824, method=immediate"
@jimbojsb
jimbojsb / gist:1990186
Created March 7, 2012 00:56
PHPMate for Sublime Text 2
import sublime, sublime_plugin
from subprocess import Popen, PIPE, STDOUT
class RunPhpCommand(sublime_plugin.TextCommand):
def run(self, edit):
content = self.view.substr(sublime.Region(0, self.view.size()))
php = Popen(['/usr/local/bin/php'], stdout=PIPE, stdin=PIPE)
php.stdin.write(content)
output = php.communicate()[0]
newtab = self.view.window().new_file()
@jimbojsb
jimbojsb / gist:2140944
Created March 20, 2012 20:26
Bamboo is dead, long live bamboo
<?php
chdir("/home/offers/www/offers-qa/coral");
`git checkout next`;
`git reset --hard HEAD`;
`git pull`;
chdir("/home/offers/www/offers-qa/orca");
`git checkout next`;
`git reset --hard HEAD`;
`git pull`;
$date = `git log --max-count=1 | grep Date`;
@jimbojsb
jimbojsb / gist:3738925
Created September 17, 2012 18:28
php configure
'./configure' '--prefix=/usr/local' '--with-config-file-path=/usr/local/etc' '--with-mysql=/usr/local/mysql' '--with-mysqli=/usr/local/mysql/bin/mysql_config' '--with-pdo-mysql=/usr/local/mysql/bin/mysql_config' '--enable-mbstring' '--with-zlib' '--with-openssl' '--with-curl' '--with-xsl' '--enable-fpm' '--enable-soap'
@jimbojsb
jimbojsb / gist:4112010
Created November 19, 2012 17:16
args problem
<?php
passthru('clear');
$args = array(1,2,3,4,5);
class Foo
{
public function bar($args)
{
$args[] = 6;
echo '$args inside Foo->bar(): ' . "\n" . print_r($args, 1);
}
@jimbojsb
jimbojsb / gist:4171673
Created November 29, 2012 20:25
deduplicator
<?php
class Deduplicator
{
protected $items = [];
public function add($item)
{
// name field will be in $item->name
$this->items[] = $item;
}
@jimbojsb
jimbojsb / gist:4208428
Created December 4, 2012 20:38
PHPStorm constructor generation idea
From this:
class FtpTransport
{
public function __construct($host, $username, $password)
{
}
}
Allow me to generate this:
@jimbojsb
jimbojsb / gist:4253495
Created December 10, 2012 21:16
kitchen sink php configure script
'./configure' \
'--prefix=/usr/local' \
'--with-config-file-path=/usr/local/etc' \
'--enable-mbstring' \
'--with-zlib' \
'--with-openssl' \
'--with-curl' \
'--enable-fpm' \
'--with-config-file-path=/usr/local/etc' \
'--enable-ftp' \
@jimbojsb
jimbojsb / gist:4696172
Created February 2, 2013 05:03
new router syntax
$router['homepage']('GET /', function() {
echo 'hi';
});
@jimbojsb
jimbojsb / gist:4942515
Last active December 13, 2015 16:48
Parse behat data tables into mongo documents
/**
* @Given /^existing "([^"]*)" with data:$/
*/
public function existingWithData($arg1, TableNode $table)
{
$collection = $arg1;
foreach ($table->getHash() as $row) {
$data = array();
foreach ($row as $key => $value) {
if (strpos($key, "[]") !== false) {