Skip to content

Instantly share code, notes, and snippets.

View travist's full-sized avatar

Travis Tidwell travist

View GitHub Profile
@travist
travist / gist:1648952
Created January 20, 2012 18:45
Determine how productive your team has been using git history.
git log --shortstat --since="1 year ago" --until="now" \
| grep "files changed\|Author\|Merge:" \
| awk '{ \
if ($1 == "Author:") {\
currentUser = $2;\
}\
if ($2 == "files") {\
files[currentUser]+=$1;\
inserted[currentUser]+=$4;\
deleted[currentUser]+=$6;\
@travist
travist / gist:1670749
Created January 24, 2012 15:41
.bashrc for bringing in GIT branches
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]:->$(__git_ps1 " (%s)")\$ '
@travist
travist / gist:1672594
Created January 24, 2012 20:59
Determine all commits for a developer given a time range.
git log --shortstat --since="2011-9-1" --until="2011-11-15" \
| grep "commit\|Author\|Merge:" \
| awk '{\
if ($1 == "Merge:") {\
merge = 1;\
}\
if ($1 == "commit") {\
merge = 0;\
commit = $2;\
}\
@travist
travist / gist:1677353
Created January 25, 2012 17:09
Determine the diff provided a Story ID.
git log\
| grep "Merge pull request.*{INSERT STORY ID HERE}" -B 5\
| awk '{\
if ($1=="commit") {\
print system("git diff " $2 "^ " $2);\
}\
}'
@travist
travist / gist:1760058
Created February 7, 2012 14:50
Using GIT to determine all changes to a file provided a date range.
git log --shortstat --since="3 weeks ago" --until="now" \
| grep "Merge pull request" -B 5\
| awk '{\
if ($1=="commit") {\
output = system("git diff " $2 "^ " $2 " {YOUR FILE HERE}");\
if (output) {\
print output;\
}\
}\
}'
@travist
travist / gist:1942541
Created February 29, 2012 17:12
Determine every event that gets fired on your page.
(function($) {
$('*').each(function() {
var e = $.data(this, 'events');
if(!e) return;
for(var p in e) {
$(this).bind(p, {event:p, name: this.tagName + '.' + this.className}, function(event) {
console.log(event.data.name + " triggered " + event.data.event);
});
};
});
@travist
travist / gist:2562314
Created April 30, 2012 20:10
Warning: remote port forwarding failed for listen port 9000
Do the following to fix this error.
ttidwell@a:~:->$ sudo lsof|grep 9000
sshd 31533 ttidwell 9u IPv6 506614 0t0 TCP [::1]:9000 (LISTEN)
sshd 31533 ttidwell 10u IPv4 506615 0t0 TCP localhost:9000 (LISTEN)
ttidwell@a:~:->$ kill 31533
@travist
travist / gist:2694333
Created May 14, 2012 14:31
To use weinre to debug mobile Drupal sites.
/**
* Add this to your module file.
*/
function mymodule_init() {
drupal_add_js('http://192.168.1.5:8080/target/target-script-min.js#anonymous', array(
'type' => 'external',
'group' => JS_LIBRARY,
'weight' => -1000
));
}
@travist
travist / gist:2863998
Last active October 5, 2015 19:37
Dynamically add javascript to your page
// Conditionally loads scripts.
var loadScripts = function(params) {
// Iterate over each source.
var eachSource = function(callback) {
if (typeof params.scripts == 'string') {
callback(params.scripts);
}
else {
for (var i=0; i < params.scripts.length; i++) {
@travist
travist / gist:2914228
Created June 12, 2012 02:48
Ignoring a modified settings.php (Drupal) file if managed in GIT.
git update-index --assume-unchanged sites/default/settings.php