Skip to content

Instantly share code, notes, and snippets.

View bench_php_static.php
<?php
class A {
private static $__value = 'Foo';
public function getValue() {
return self::$__value;
}
}
class B {
View crc32_md5_sha1_bench.php
<?php
$string = uniqid();
$start = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
crc32($string);
}
$elapsed = microtime(true) - $start;
echo "crc32 => $elapsed\n";
View bench.php
<?php
/**
* Configuration options
*
*/
$iterations = 10000000;
info();
/**
* Actual Benchmarks to run
View gource-gravatar.php
#!/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 Nov 1, 2010
Automatically generate changelogs for CakePHP
View changelog-cakephp.php
<?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"}\'',
View gist:704596
// --- Controller
class TestsController extends Controller {
public $uses = array();
public function add() {
$x = new App();
$x->__cache = 1;
@predominant
predominant / cdcupdate.php
Created Dec 22, 2010
CakeDC repo downloader, and updater. For the truly lazy.
View cdcupdate.php
#!/usr/bin/php
<?php
if ($argc <= 1) {
$account = 'CakeDC';
} else {
$account = $argv[1];
}
if ($argc <= 2) {
@predominant
predominant / assetpaths.sh
Created Feb 10, 2011
CakePHP asset symlinking
View assetpaths.sh
#!/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 Feb 21, 2011
Creates dumps from CakePHP database configurations
View CakePHP Database dumping
#!/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);
View 10-ways-to-improve-github-issues.md

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.