Skip to content

Instantly share code, notes, and snippets.

View rex's full-sized avatar

ᴘɪᴇʀᴄᴇ ᴍᴏᴏʀᴇ™ rex

View GitHub Profile
@rex
rex / atom-regexes.md
Last active April 19, 2016 17:40
Atom Regexes

Atom Editor Regexes

Operate on all project files easily with global search/replace

File search glob

When running 'find and replace' in entire project

app/webroot/js/!(build)/**/*.js

@rex
rex / commitfail-pre-hook.sh
Last active December 27, 2016 13:51
Git pre-commit hook that will detect COMMITFAIL, @COMMITFAIL, NOCOMMIT, or @nocommit and fail the commit.
#!/bin/bash
echo "Arguments:"
echo $@
echo "---"
FILES_PATTERN='(\..+)?$'
FORBIDDEN='(@?NOCOMMIT|@?COMMITFAIL)'
if ( git diff --cached --name-only | grep -E $FILES_PATTERN | xargs grep -E --with-filename -n $FORBIDDEN ); then
echo "ERROR: @COMMITFAIL or @NOCOMMIT found. Exiting to save you from yourself."
@rex
rex / dina.html
Last active December 10, 2015 20:26
Because Dina is a huge PITA
<input type="text" class="js-format-currency" value="12345.00" />
PLATFORM=$(uname)
ISLINUX=0
WORKING_DIR=$(pwd)
CONFIG_DIR=$(cd ../config && pwd)
if [ $PLATFORM = 'Linux' ]; then
ISLINUX=1
OS_CODENAME=$(lsb_release -cs)
else
OS_CODENAME="trusty"
@rex
rex / run-tests.rb
Created August 4, 2015 22:58
Run some or all kitchen tests using converge and verify
#!/usr/bin/env ruby
require 'colorize'
require 'open3'
require 'benchmark'
require 'optparse'
class TestRunner
attr_accessor :converge_enabled, :verify_enabled
@rex
rex / Vagrantfile
Last active August 29, 2015 14:26 — forked from tmatilai/Vagrantfile
My global Vagrant configuration (~/.vagrant.d/Vagrantfile)
# URI of the local (caching) HTTP proxy
LOCAL_HTTP_PROXY = 'http://192.168.33.200:8123'
# Configures vagrant-cachier and vagrant-proxyconf.
# Should be called only on "local machine" providers.
def configure_caching(config)
if Vagrant.has_plugin?('vagrant-cachier')
config.cache.enable_nfs = true
config.cache.enable :gem
config.cache.enable :npm
{
"TODO": "TODO[\\s]*?:[\\s]*(?P<todo>.*)$",
"NOTE": "NOTE[\\s]*?:[\\s]*(?P<note>.*)$",
"FIXME": "FIX ?ME[\\s]*?:[\\s]*(?P<fixme>.*)$",
"CHANGED": "CHANGED[\\s]*?:[\\s]*(?P<changed>.*)$",
"CONSOLE": "console\\.(log|warn|error|notice)\\((?P<console>.*)\\);?$"
}
@rex
rex / favorite-libraries.md
Last active July 29, 2018 12:50
A list of my favorite libraries, grouped for sanity
@rex
rex / platform-detect.coffee
Created February 26, 2015 00:37
Super, dead simple browser & platform detection. Found on this awesome blog post: http://davidlesches.com/blog/making-browsers-play-nice-with-thin-fonts
$ ->
is_chrome = navigator.userAgent.indexOf('Chrome') > -1
is_explorer = navigator.userAgent.indexOf('MSIE') > -1
is_firefox = navigator.userAgent.indexOf('Firefox') > -1
is_safari = navigator.userAgent.indexOf("Safari") > -1
is_opera = navigator.userAgent.indexOf("Presto") > -1
is_mac = (navigator.userAgent.indexOf('Mac OS') != -1)
is_windows = !is_mac
if is_chrome && is_safari
@rex
rex / locate-largest-git-objects.sh
Created February 15, 2015 05:38
Bash script to find the largest objects in a Git repo. I DID NOT WRITE THIS. I found this in a fantastic blog post by Antony Stubbs - https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
#!/bin/bash
#set -x
# Shows you the largest objects in your repo's pack file.
# Written for osx.
#
# @see https://stubbisms.wordpress.com/2009/07/10/git-script-to-show-largest-pack-objects-and-trim-your-waist-line/
# @author Antony Stubbs
# set the internal field spereator to line break, so that we can iterate easily over the verify-pack output