Skip to content

Instantly share code, notes, and snippets.

Daniel Cox danielpcox

Block or report user

Report or block danielpcox

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
danielpcox /
Created Feb 12, 2015 identity proof

Keybase proof

I hereby claim:

  • I am danielpcox on github.
  • I am danielpcox ( on keybase.
  • I have a public key whose fingerprint is D085 A81C CE7C 291D 7A9E 1F70 14DA 0F0F BB08 2FEE

To claim this, I am signing this object:

danielpcox /
Created Apr 24, 2014
Run a command in all tmux panes of the current window
# Runs the specified command (all arguments together) in all tmux panes in the current window
# Notate which window/pane we were originally at
window=`tmux display-message -p '#I'`
ORIG_PANE_INDEX=`tmux display-message -p '#P'`
danielpcox / extract_subdir_slim_history.txt
Last active Aug 29, 2015
Extract subdirectory in git, then slim down the history
View extract_subdir_slim_history.txt
$ git clone blahblahblah # <-- fresh clone of the repo
$ du -sh .
768M # <-- holy macaroni, that's huge
$ git filter-branch --subdirectory-filter path/to/subdir --prune-empty --tag-name-filter cat -- --all # <-- Actual filter
### Now we'll delete all references to those unchanged refs
$ git reflog expire --expire=now --all # <-- expire the reflog refs
danielpcox /
Last active Dec 25, 2015
Simple Dev Box

Simple Dev Box

Spins up a very simple VM and installs a few important things.


danielpcox / retrync
Last active Dec 21, 2015
retrync ("retrying rsync") executes resumable rsync uploading/downloading via SSH with progress over and over until the transfer is complete. First stick your public SSH key in ~/.ssh/authorized_keys on the remote server. Original version came from
View retrync
# Usage: retrync path/to/thing/locally user@host:/path/where/you/want/it/remotely
trap "echo Exited!; exit;" SIGINT SIGTERM
while [ $? -ne 0 ]
danielpcox /
Created Jul 4, 2013
Simple, static, global configuration. Depends on Log4j and Guava.
import java.util.Properties;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
danielpcox /
Last active Dec 16, 2015
Merge the root of a given branch from repository A into a subdirectory of a given branch in the current repository, preserving yet rewriting the history so that it looks as if A had always been developed inside that subdirectory. It also rewrites the tags to point to the new commits, appending the subdirectory name to the tag names to avoid conf…
#!/usr/bin/env sh
# USAGE: <subdirectory-name> <new-local-branch-name> <remote-branch-name> <remote-repository-url>
# <new-local-branch> will be created it it does not already exist
danielpcox /
Last active Dec 11, 2015
Creating a new Rails Engine "blorgh" with RSpec and YARD

Creating a new Rails Engine "blorgh" w/ RSpec + YARD

I did all of the following with Rails 3.2.12 and Bundler 1.3.0 acquired with

$> gem install --version '3.2.12' rails
$> gem install --version '1.3.0' bundler

Start by using Rails' Engine generator with a few options.

$> rails plugin new blorgh --full --dummy-path=spec/dummy \
View gist:2989641

Git Crash Course

Git is a source code management system.

Third Level


danielpcox /
Created Jun 14, 2012
A little Java snippet for reading a file into a string.
private static String readFileAsString(String filePath)
StringBuffer fileData = new StringBuffer(1000);
BufferedReader reader = new BufferedReader(
new FileReader(filePath));
char[] buf = new char[1024];
int numRead=0;
while(( != -1){
String readData = String.valueOf(buf, 0, numRead);
You can’t perform that action at this time.