Skip to content

Instantly share code, notes, and snippets.

💃

Joseph Wynn wildlyinaccurate

💃
View GitHub Profile
@wildlyinaccurate
wildlyinaccurate / Git.md
Created Oct 24, 2011
A comparison of Git and SVN. Or, why you should switch to Git.
View Git.md
   	                                	  ,ad8888ba,   88           
                                   		d8"'    `"8b  ""    ,d     
                                   		d8'                  88     
                                   		88             88  MM88MMM  
                                   		88      88888  88    88     
                                   		Y8,        88  88    88     
                                   		 Y8a.    .a88  88    88,    
                                   		  `"Y88888P"   88    "Y888  
View recursive_array_search.php
<?php
/**
* Recursively search an array for a given value. Returns the root element key if $needle
* is found, or FALSE if $needle cannot be found.
*
* @param mixed $needle
* @param array $haystack
* @param bool $strict
* @return mixed|bool
View AccountControllerTest.php
<?php
require_once 'ControllerTestCase.php';
class AccountControllerTest extends ControllerTestCase
{
public function testSignupWithNoDataRedirectsAndHasErrors()
{
$response = $this->post('account@signup', array());
@wildlyinaccurate
wildlyinaccurate / queue.js
Created Jul 18, 2012
Really simple Javascript queueing system
View queue.js
var Queue = function() {
var isInit = false;
var queue = [];
return {
onInit: function(callback) {
if (isInit) {
callback();
@wildlyinaccurate
wildlyinaccurate / event.js
Last active Nov 8, 2019
Really simple Javascript custom event system
View event.js
var Event = function() {
var self = this;
self.queue = {};
self.fired = [];
return {
fire: function(event) {
@wildlyinaccurate
wildlyinaccurate / akamai_not_cacheable_replayer.rb
Created Aug 1, 2012
Log replayer that flags URLs where the X-Check-Cacheable header returned by Akamai is NO
View akamai_not_cacheable_replayer.rb
=begin
This script will replay an Apache log file and verify whether each request
is cacheable by Akamai.
To run the script, provide the log file and your Akamai origin host name as
arguments, for example:
replayer.rb /var/log/apache/access.log http://dsd-www.example.com.edgesuite-staging.net
=end
require 'net/http'
@wildlyinaccurate
wildlyinaccurate / Preferences.sublime-settings
Last active Oct 14, 2015
My Sublime Text configuration
View Preferences.sublime-settings
{
"theme": "Soda Dark.sublime-theme",
"color_scheme": "Packages/Theme - Refined/Color Schemes/Monokai Refined.tmTheme",
"font_face": "Droid Sans Mono",
"font_size": 12,
"font_options": ["no_italic"],
"highlight_line": true,
"line_padding_top": 3,
"line_padding_bottom": 3,
@wildlyinaccurate
wildlyinaccurate / convert-tabs-and-trim-trailing-whitespace.sh
Last active Dec 11, 2015
Convert tabs to 4 spaces and trim any trailing whitespace
View convert-tabs-and-trim-trailing-whitespace.sh
# This requires GNU sed (or any sed which supports -i) and expand
find . -type f -printf "sed -i 's/[ \t]*$//' %p && expand -t 4 %p > %p.tmp && mv %p.tmp %p\n" | sh
# It's better to be more specific about which files you want to run the replacement in, e.g.
find . -type f -name *.php -printf "sed -i 's/[ \t]*$//' %p && expand -t 4 %p > %p.tmp && mv %p.tmp %p\n" | sh
# You can use find's -regex option to match multiple extensions (you need to double-escape backslashes in bash):
find . -type f -regex .+\\\.\\\(php\\\|css\\\|js\\\)\$ -printf "sed -i 's/[ \t]*$//' %p && expand -t 4 %p > %p.tmp && mv %p.tmp %p\n" | sh
@wildlyinaccurate
wildlyinaccurate / watch.sh
Last active Dec 14, 2015
Simple script to run the CoffeeScript and Sass "watch" commands
View watch.sh
#!/bin/bash
PIDFILE=".watch.pid"
touch $PIDFILE || (echo "Unable to write to .watch.pid" && exit 1)
# Kill off old processes
while read pid; do
kill $pid
done < $PIDFILE
View hack.sh
#!/usr/bin/env sh
##
# This is script with usefull tips taken from:
# https://github.com/mathiasbynens/dotfiles/blob/master/.osx
#
# install it:
# curl -sL https://gist.githubusercontent.com/wildlyinaccurate/5539084/raw/hack.sh | sh
#
You can’t perform that action at this time.