Skip to content

Instantly share code, notes, and snippets.

View predominant's full-sized avatar
🦄

Graham Weldon predominant

🦄
View GitHub Profile
<?php
class A {
private static $__value = 'Foo';
public function getValue() {
return self::$__value;
}
}
class B {
<?php
$string = uniqid();
$start = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
crc32($string);
}
$elapsed = microtime(true) - $start;
echo "crc32 => $elapsed\n";
<?php
/**
* Configuration options
*
*/
$iterations = 10000000;
info();
/**
* Actual Benchmarks to run
#!/opt/local/bin/php
<?php
// Get a git log
$log = trim(`git shortlog -s -n -e`);
$log = explode("\n", $log);
// Clean and make a new directory for images.
`rm -rf gource-gravatars`;
mkdir('gource-gravatars');
@predominant
predominant / changelog-cakephp.php
Created November 1, 2010 15:23
Automatically generate changelogs for CakePHP
<?php
$options = array(
'repo' => '/Users/predominant/Projects/cakephp/2.0/.git',
'titleOrder' => array(
'dev', 'alpha', 'beta', 'rc',
),
'regex' => '/(?<version>[\d\.]+)(?:-(?<title>[a-zA-Z]+)(?:(?<iteration>\d)?))?/',
'formats' => array(
'plaintext' => '| awk \'{print "Commit: ["$1"]\n"; $1=""; print "-"$0"\n"}\'',
'lighthouse' => '| awk \'{print "#### Commit: ["$1"](http://github.com/cakephp/cakephp/commit/"$1")\n"; $1=""; print $0"\n"}\'',
// --- Controller
class TestsController extends Controller {
public $uses = array();
public function add() {
$x = new App();
$x->__cache = 1;
@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) {
@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 / 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);

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.