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
danielpcox / keybase.md
Created Feb 12, 2015
Keybase.io identity proof
View keybase.md

Keybase proof

I hereby claim:

  • I am danielpcox on github.
  • I am danielpcox (https://keybase.io/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
danielpcox / allpanes.sh
Created Apr 24, 2014
Run a command in all tmux panes of the current window
View allpanes.sh
#!/bin/bash
# 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'`
command=$@
@danielpcox
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
danielpcox / README.md
Last active Dec 25, 2015
Simple Dev Box
View README.md

Simple Dev Box

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

Usage

@danielpcox
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 http://blog.iangreenleaf.com/2009/03/rsync-and-retrying-until-we-get-it.html
View retrync
#!/bin/bash
# Usage: retrync path/to/thing/locally user@host:/path/where/you/want/it/remotely
trap "echo Exited!; exit;" SIGINT SIGTERM
false
while [ $? -ne 0 ]
do
@danielpcox
danielpcox / Config.java
Created Jul 4, 2013
Simple, static, global configuration. Depends on Log4j and Guava.
View Config.java
package rmt.analytics.tagger.configuration;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@danielpcox
danielpcox / merge-remote.sh
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…
View merge-remote.sh
#!/usr/bin/env sh
# USAGE: merge-remote.sh <subdirectory-name> <new-local-branch-name> <remote-branch-name> <remote-repository-url>
#
# <new-local-branch> will be created it it does not already exist
SUBDIR_NAME=$1
LOCAL_BRANCH=$2
REMOTE_BRANCH=$3
REMOTE_URL=$4
@danielpcox
danielpcox / rails_engine.md
Last active Dec 11, 2015
Creating a new Rails Engine "blorgh" with RSpec and YARD
View rails_engine.md

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

text

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