Skip to content

Instantly share code, notes, and snippets.

View wildlyinaccurate's full-sized avatar
🐕‍🦺

Joseph Wynn wildlyinaccurate

🐕‍🦺
View GitHub Profile
@wildlyinaccurate
wildlyinaccurate / morph-module-checklist.md
Last active April 18, 2017 14:33
Morph module PR checklist
@wildlyinaccurate
wildlyinaccurate / recursive_array_search.php
Created April 23, 2012 21:39
PHP Recursive Array Search
<?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
@wildlyinaccurate
wildlyinaccurate / monitor-concurrent-commands.sh
Created October 3, 2013 08:56
A simple way of checking the exit code of commands which have been run concurrently.
sleep_times=('4' '1' '2' '5' '0')
pids=()
for sleep_time in ${sleep_times[@]}
do
sleep $sleep_time &
pids=(${pids[@]} $!)
done
for pid in ${pids[@]}
@wildlyinaccurate
wildlyinaccurate / xranr-force-resolution.sh
Created September 27, 2013 14:49
Force X to use a certain screen resolution
# Ad-hoc
xrandr --newmode 1920x1080 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
xrandr --addmode VBOX0 1920x1080
xrandr --output VBOX0 --mode 1920x1080
# Or in ~/.i3/config
# exec_always xrandr --newmode 1920x1080 173.00 1920 2048 2248 2576 1080 1083 1088 1120 -hsync +vsync
# exec_always xrandr --addmode VBOX0 1920x1080
# exec_always xrandr --output VBOX0 --mode 1920x1080
@wildlyinaccurate
wildlyinaccurate / rebase1
Created May 21, 2013 13:50
Complete the `rebase1` level of Learn Git Branching in 6 moves - http://pcottle.github.io/learnGitBranching/
git checkout another
git rebase side
git rebase bugFix
git rebase master
git checkout master
git rebase another
@wildlyinaccurate
wildlyinaccurate / Sublime Packages.txt
Created May 9, 2013 19:32
Packages I use to develop in Sublime Text 3 (PHP, JavaScript, CoffeeScript, SCSS, Ruby, Behat/Gherkin)
All Autocomplete
CoffeeScript
DocBlockr
Markdown Preview
Package Control
Sass
SideBarEnhancements
SublimeCodeIntel
SublimeLinter
SyncedSideBar
@wildlyinaccurate
wildlyinaccurate / Default (Linux).sublime-keymap
Last active December 17, 2015 02:59
My Sublime Text keymap configuration
[
{ "keys": ["ctrl+d"], "command": "duplicate_line" },
{ "keys": ["ctrl+shift+d"], "command": "run_macro_file", "args": {"file": "res://Packages/Default/Delete Line.sublime-macro"} },
{ "keys" : ["ctrl+shift+down"], "command" : "swap_line_down"},
{ "keys" : ["ctrl+shift+up"], "command" : "swap_line_up"},
{ "keys": ["ctrl+shift+o"], "command": "prompt_open_folder" },
{ "keys": ["ctrl+s"], "command": "save_all" },
{ "keys": ["ctrl+shift+w"], "command": "close_all" }
]
@wildlyinaccurate
wildlyinaccurate / hack.sh
Last active December 17, 2015 02:49 — forked from erikh/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
#
@wildlyinaccurate
wildlyinaccurate / watch.sh
Last active December 14, 2015 11:58
Simple script to run the CoffeeScript and Sass "watch" commands
#!/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
@wildlyinaccurate
wildlyinaccurate / convert-tabs-and-trim-trailing-whitespace.sh
Last active December 11, 2015 22:59
Convert tabs to 4 spaces and trim any trailing whitespace
# 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