Skip to content

Instantly share code, notes, and snippets.

View aholmes's full-sized avatar

Aaron Holmes aholmes

View GitHub Profile
<?php
class HTTP {
protected _statusCode;
protected function _getStatusCode() {
return $this._statusCode;
}
protected _url;
protected function _getUrl() {
#!/bin/bash
FAILURE=0
do_tasks() {
if [[ $FAILURE -eq 0 ]]; then
echo -e "Running tasks\n"
some_command &
some_command &
some_command &
@aholmes
aholmes / Traverse.php
Last active January 2, 2016 14:49
The OOP version of https://igor.io/2014/01/08/functional-library-traversal.html for ghits and shiggles.
<?php
class Traverse implements ArrayAccess {
protected $container;
function __construct($array) {
$this->container = $array;
}
public function offsetExists($offset) {
return isset($this->container[$offset]);
}
@aholmes
aholmes / apc_overloads.php
Created December 23, 2013 19:49
Overload apc_fetch and apc_add as a quick replacement for APC methods on systems that don't support it (like PHP 5.5 on OSX). These methods are not an exact reimplementation of the defined documentation on http://php.net. TTL is ignored, for one.
<?php
// apc crashed on my dev box, so overload the methods if they don't exist
if (!function_exists('apc_fetch')) {
function apc_fetch($key, &$success) {
if (!($filename = apc_get_tmpfile($key, $f))) {
return false;
}
if (!($d = fread($f, filesize($filename)))) {