Skip to content

Instantly share code, notes, and snippets.

@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: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 / 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 / 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 / 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)
<?php
class BaseDecorator {
private $component;
private $methods = array();
private $properties = array();
public function __construct($component) {
$this->component = $component;
}
@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",
@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 / ShutdownFunctionManager.php
Created May 30, 2013 13:42
Simple PHP shutdown function manager
<?php
class ShutdownFunctionManager {
protected $callbacks = array();
protected $registered = false;
public function __construct($auto_register = true) {
if ($auto_register) {
$this->register();
}
@gcatlin
gcatlin / multiple-error-handlers.php
Created May 30, 2013 13:53
Adds support for multiple error handlers in PHP
<?php
function append_error_handler($handler) {
set_error_handlers(array(set_error_handler($handler), $handler));
}
function prepend_error_handler($handler) {
set_error_handlers(array($handler, set_error_handler($handler)));
}