Skip to content

Instantly share code, notes, and snippets.

View predominant's full-sized avatar
🦄

Graham Weldon predominant

🦄
View GitHub Profile
@predominant
predominant / AppModel.php
Created December 14, 2011 05:47
Automatic table creation for missing tables.
<?php
class AppModel extends Model {
/**
* Overridden setSource allows creation of table in the event a MissingTableException is raised.
*
* @param string $tablename Table name
* @return void
*/
public function setSource($tablename) {
@predominant
predominant / fabfile.py
Created December 11, 2011 04:52
grahamweldon.com fabfile
from __future__ import with_statement
from datetime import datetime
from sys import exit
from fabric.api import env, run, local, task, settings, sudo
import re
env.hosts = ['www-data@grahamweldon.com']
environments = {
'__base__': {
@predominant
predominant / .bash_logout
Created December 8, 2011 04:39
Automatic operations on logout from a server
#!/bin/bash
##
## Commit configuration files.
##
if [ ! -d /etc/.git ]; then
cd /etc
git init
git config user.name "Server Administrator"
git config user.email "root@localhost"
@predominant
predominant / ubuntu-1104-nginx-base.sh
Created October 5, 2011 15:19
Install Ubuntu 11.04 Nginx based web server with PHP-FPM, MySQL and MongoDB
#!/bin/bash
###
#
# Copyright (c) 2011 Cake Development Corporation (http://cakedc.com)
#
# Ubuntu 11.04 based web server installation script
# Run this by executing the following from a fresh install of Ubuntu 11.04 server:
#
# bash -c "$(curl -fsSL https://raw.github.com/gist/1264701)" <mysqlPassword>
@predominant
predominant / jigo_cache.php
Created May 30, 2011 07:23
Cache override
<?php
App::import('Helper', 'Cache');
class JigoCacheHelper extends CacheHelper {
public function __construct() {
$view = ClassRegistry::getObject('view');
$view->Cache = $this;
$view->loaded['cache'] = $this;
}

10 Ways to improve Github Issues

I love the new GitHub issues, here are some ideas to make it perfect, ordered by priority:

1. I should be able to pick the assignee and milestone via keyboard when creating a new ticket

2. Keyboard shortcuts should work everywhere. E.g. when viewing an existing issue, 'c' does not work.

3. After creating an issue, the assigned user / milestone should be remembered and pre-filled.

4. Allow assigning a different user while commenting. Right now this deletes my half-typed comment.

5. When typing the @ symbol to mention somebody, it should auto-complete the name.

6. Things feel a little sluggish right now, any speed improvements would be very welcome.

@predominant
predominant / CakePHP Database dumping
Created February 21, 2011 09:24
Creates dumps from CakePHP database configurations
#!/usr/bin/php
<?php
if (!defined('TMP')) {
define('TMP', getcwd() . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR);
}
$file = getcwd() . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'database.php';
if (!is_readable($file)) {
echo "Can't find database config at : $file\n";
die(1);
@predominant
predominant / assetpaths.sh
Created February 10, 2011 14:52
CakePHP asset symlinking
#!/bin/bash
if [ ! -d "webroot" ]; then
echo "Doesn't look like a CakePHP application."
echo "Make sure you are in the APP directory."
exit 1
fi
cd webroot
@predominant
predominant / cdcupdate.php
Created December 22, 2010 23:13
CakeDC repo downloader, and updater. For the truly lazy.
#!/usr/bin/php
<?php
if ($argc <= 1) {
$account = 'CakeDC';
} else {
$account = $argv[1];
}
if ($argc <= 2) {
// --- Controller
class TestsController extends Controller {
public $uses = array();
public function add() {
$x = new App();
$x->__cache = 1;