Skip to content

Instantly share code, notes, and snippets.

View pfhawkins's full-sized avatar

P.F. Hawkins pfhawkins

View GitHub Profile
em() {
daemonproc=$(ps faux | egrep "emacs --daemon" | egrep -vc "egrep")
if [ $daemonproc = 1 ]; then
emacsclient -t $1
else;
emacs --daemon
emacsclient -t $1
fi
}
@pfhawkins
pfhawkins / natread.py
Created December 7, 2009 21:14 — forked from simonw/natread.py
tweaked to use my username, cowsay instead of cowthink (per ubuntu)
#!/usr/bin/python
import json, urllib, os, textwrap
user = 'pfhawkins'
url = "http://twitter.com/statuses/user_timeline/%s.json"
pipe = os.popen("cowsay -n", 'w')
pipe.write('\n'.join(textwrap.wrap(
json.load(urllib.urlopen(url % user))[0]['text'])
))

Badass git pull alternative

Add this little snippet to your ~/.gitconfig and it amps up your git pull by means of git up

  1. Adds in a list of the commits you're pulling down
  2. Auto-prunes remote branches
  3. Defaults to pull --rebase - gets rid of unnecessary merge commits. If you don't know what rebase does, this is probably safe for you. If you know what rebase does, you should know where this will not be safe for you.

Scott Chacon and Ryan Tomayko basically figured out how to do this and I am stealing all of the credit.

# require the libraries to make it all work
require 'rubygems'
require 'active_support/core_ext'
require 'business_time'
# What time is it now? Of course, this will be different
# for you, so your relative answrs below will vary
# accordingly:
Time.now
@pfhawkins
pfhawkins / macup.rb
Created January 3, 2012 20:55
upcases portions of a MAC address for some work copypasta
#!/usr/bin/env ruby
# Takes a single MAC address as an argument, returns it with the
# letters capitalized (both to STDOUT and clipboard)
# Example:
#
# ruby macup.rb 00:14:d1:13:97:c4
#
# will return:
@pfhawkins
pfhawkins / flatten.xslt
Created January 24, 2012 21:16 — forked from nicferrier/flatten.xslt
flatten
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:str="http://exslt.org/strings"
xmlns:re="http://exslt.org/regular-expressions"
extension-element-prefixes="str regexp"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:output mode="text" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:apply-templates select="//table//tr" mode="variables">
# put this at ~/.gitconfig
[alias]
# I'm lazy, so two letters will always trump the full command
co = checkout
ci = commit
cp = cherry-pick
st = status
br = branch
unbind C-b
set -g prefix C-a
bind-key V select-layout even-horizontal
bind-key H select-layout even-vertical
bind-key T select-layout tiled
bind-key S set-window-option synchronize-panes on
bind-key s set-window-option synchronize-panes off
bind-key j command-prompt -p "join pane from:" "join-pane -s '%%'"
bind-key k command-prompt -p "sent pane to:" "join-pane -t '%%'"
bind-key C-right swap-window -t -1
require 'spidr'
require 'graphviz'
url_map = Hash.new { |hash,key| hash[key] = [] }
Spidr.site('http://hypervers.es/') do |spider|
spider.every_link do |origin, dest|
if dest.host == "hypervers.es"
if dest.path == '/stylesheets/all.css'
elsif dest.path == '/javascripts/all.js'

Keybase proof

I hereby claim:

  • I am pfhawkins on github.
  • I am pfhawkins (https://keybase.io/pfhawkins) on keybase.
  • I have a public key ASDI-PPN43-zdGILtmeLF8ia6DfUJpZUThyp9u9bcNCGqAo

To claim this, I am signing this object: