Skip to content

Instantly share code, notes, and snippets.

@jglenes
jglenes / aaup-join-form.js
Created September 15, 2017 17:36
Join Form Tweaks
/* Include Band #'s with Donation Labels' */
(function($){
var iframe = document.getElementById("can_embed_iframe"); // Get the iFrame with the Form
var innerDoc = iframe.contentDocument || iframe.contentWindow.document; // Address iFrame as contentDocument
var labels = innerDoc.getElementsByClassName("donate_amount"); // Array of <label> HTML objects
for (i = 0, band = 1; i < labels.length; i++, band++) { // i = label array, band = band #
labels[i].innerText = "Band " + band + ": \n" + labels[i].innerText;
}
})(jQuery);
# Change the number of digits displayed on ggplot axes
# Define a number formatting function
fmt <- function(ndec) {
function(x) format(x,nsmall=ndec)
}
ggplot(mpg, aes(x=mpg$displ,y=mpg$hwy)) +
geom_point() +
scale_x_continuous(labels=fmt(2)) +
@jglenes
jglenes / gist:3018166
Created June 29, 2012 14:08
Bash Git Branch
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1="\n\[$BPurple\][\w]\n\[$BCyan\]\u@\h \[$BGreen\]\$(parse_git_branch)\n$\[$Color_Off\] "