Skip to content

Instantly share code, notes, and snippets.

@dbtlr
dbtlr / .gitconfig
Last active December 27, 2015 04:48
[alias]
# View the SHA, description, and history graph of the latest 20 commits
l = log --pretty=oneline -n 20 --graph
lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
changes = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\" --name-status
short = log --pretty=format:\"%h %cr %cn %Cgreen%s%Creset\"
changelog = log --pretty=format:\" * %s\"
shortnocolor = log --pretty=format:\"%h %cr %cn %s\"
# View the current working tree status using the short format
s = status
#!/usr/bin/env bash
# Take all the changes and run them through PHP Lint. Let the commit fail if this fails.
git diff --cached --name-status | awk '{ if ($1 != "D") print $2}' | grep -e \.php$ | xargs -n1 php -l
exit $?
@dbtlr
dbtlr / .inputrc
Created October 28, 2013 19:29
Bash inputrc with history searching
# Make Tab autocomplete regardless of filename case
set completion-ignore-case on
# List all matches in case multiple possible completions are possible
set show-all-if-ambiguous on
# Immediately add a trailing slash when autocompleting symlinks to directories
set mark-symlinked-directories on
# Use the text that has already been typed as the prefix for searching through
@dbtlr
dbtlr / sitemap.xml.haml
Last active March 10, 2017 18:55
Sitemap.xml file in HAML for Middleman.
<?xml version="1.0" encoding="UTF-8"?>
- pages = sitemap.resources.find_all{ |page| page.source_file.match(/\.html/) and not page.source_file.match(/source\/test\// ) }
-# Fill this array in with pages you don't want in the sitemap.
- excluded_paths = ['404']
- host = "http://yoursite.com/"
%urlset{ :xmlns => "http://www.sitemaps.org/schemas/sitemap/0.9" }
%url
%loc= host
%priority 0.3
%lastmod= DateTime.now.to_time.iso8601
@dbtlr
dbtlr / .bash_profile
Created July 31, 2012 02:13
Fancy command prompt
# PS1 Prompt Style Script
function parse_git_branch {
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
echo " ("${ref#refs/heads/}")"
}
# PS1 prompt color vars
RED="\[\033[1;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
@dbtlr
dbtlr / webrick.rb
Created July 25, 2012 19:51
WEBrick command line server
#!/usr/bin/ruby
require 'webrick'
require 'optparse'
options = { :port => 4000, :host => 'localhost', :root => '.' }
OptionParser.new do |opts|
opts.banner = "Usage: webrick.rb [options]"
opts.on("-p", "--port [port]", "Set the port to use, defaults to 4000.") do |p|