Skip to content

Instantly share code, notes, and snippets.

@gcatlin
gcatlin / phpunit.xml
Created January 21, 2013 18:32
Print slowest PHPUnit tests
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
printerClass="ProfilerPrinter"
printerFile="profiler.php"
>
</phpunit>
@gcatlin
gcatlin / composer.json
Last active December 11, 2015 06:18
Add dependency on a github project that doesn't support Composer.
{
"name": "my-github-username/my-project-name",
"description": "Project description goes here",
"repositories": {
"other-github-username/other-github-project-name": {
"type": "package",
"package": {
"name": "other-github-username/other-github-project-name",
"version": "dev-master",
<?php
class BaseDecorator {
private $component;
private $methods = array();
private $properties = array();
public function __construct($component) {
$this->component = $component;
}
@gcatlin
gcatlin / gist:3811614
Created October 1, 2012 12:50
brew upgrade vim 7.3.672 failure
$ brew doctor
Your system is raring to brew.
$ brew -v upgrade
Homebrew 0.9.3
==> Upgrading vim
==> Cloning https://vim.googlecode.com/hg/
Updating /Library/Caches/Homebrew/vim--hg
/usr/local/bin/hg pull
warning: vim.googlecode.com certificate with fingerprint af:26:ef:84:56:0d:c7:67:a8:86:8b:58:38:44:51:96:e4:90:bd:b2 not verified (check hostfingerprints or web.cacerts config setting)
@gcatlin
gcatlin / summarize.php
Created September 21, 2012 15:46
crappy ab output parser
<?php
$files = array_slice($argv, 1);
echo "[cache],[concurrency_level],[time],[requests],[failures],[requests_per_second],[time_per_request],[concurrent_time_per_request],[transfer_rate],[p50],[p66],[p75],[p80],[p90],[p95],[p98],[p99],[max]\n";
foreach ($files as $file) {
if (in_array(array('run', 'summarize.php'), $files)) {
continue;
}
@gcatlin
gcatlin / ncurses.diff
Created July 12, 2012 14:28
Homebrew Ncurses clang patch
diff --git a/ncurses.rb b/ncurses.rb
index 1067083..8cc12bc 100644
--- a/ncurses.rb
+++ b/ncurses.rb
@@ -23,4 +23,9 @@ class Ncurses < Formula
system "make"
system "make install"
end
+
+ def patches
@gcatlin
gcatlin / gist:2989928
Created June 25, 2012 17:09
Django middleware for handling non-multipart uploads
class ApplicationOctetStreamHandlerMiddleware():
def process_request(self, request):
# @TODO support base64 encoding
# @TODO support content-disposition header and filename
content_type = request.META.get('CONTENT_TYPE')
try:
content_length = int(request.META.get('CONTENT_LENGTH', 0))
except (ValueError, TypeError):
content_length = 0
@gcatlin
gcatlin / gist:1897059
Created February 24, 2012 03:19
Set short keyboard delay and fast repeat rate on OS X
# Source: http://quickies.seriot.ch/index.php?id=411
defaults write NSGlobalDomain InitialKeyRepeat -int 7
defaults write NSGlobalDomain KeyRepeat -int 0
@gcatlin
gcatlin / gist:1847248
Created February 16, 2012 19:43
Install specific version of Homebrew formula
brew update
brew versions FORMULA
cd `brew --prefix`
git checkout HASH Library/Formula/FORMULA.rb # use output of "brew versions"
brew install FORMULA
brew switch FORMULA VERSION
git checkout -- Library/Formula/FORMULA.rb # reset formula
## Example: Using Subversion 1.6.17
#
@gcatlin
gcatlin / gist:1845095
Created February 16, 2012 14:07
Convert audio files - m4a to mp3
# source: http://stackoverflow.com/a/5057305
# finds all the files in the current directory, converts them to mp3, using
# the original file name and changing the file extension
find . | parallel ffmpeg -i {} -ab 192k -acodec libmp3lame -ac 2 {.}.mp3