Skip to content

Instantly share code, notes, and snippets.

@kcmckell
kcmckell / ConfEmail_v1
Last active August 29, 2015 14:06
Hopu Confirmation Email
function onFormSubmit(e) {
// Initial Testing/Debugging
// var test = '';
// var appendme = '';
// for (var i = 0; i<e.values.length; i++) {
// appendme = i+': '+e.values[i];
// Logger.log(appendme);
// test += appendme+'\n';
// }
Logger.log(e);
@kcmckell
kcmckell / lt
Created July 23, 2014 22:25
Recursively list all files in a directory, sorted by modification time, filtering out 'Icon' files. [Credit](http://stackoverflow.com/questions/3400031/bash-filtering-out-directories-and-extensions-from-find)
gfind . -type f -printf "%-.22T+ %M %n %-8u %-8g %8s %Tx %.8TX %p\n" | sort | cut -f 2- -d ' ' | grep -v Icon
@kcmckell
kcmckell / git-loghtml
Created July 3, 2014 12:44
Output git log for each file to HTML
for x in `git diff --name-only FROMCOMMIT TOCOMMIT | awk '{print $1}'`; do git log --word-diff --color -U2 FROMCOMMIT..TOCOMMIT $x|tmp/ansi2html.sh > change/$x.html; done
@kcmckell
kcmckell / startup.m
Created May 22, 2014 19:41
My Matlab customization script that is run at startup.
% startup.m
disp('%%%%%%%%%%%%%%%%');
disp('Startup Commands in:');
disp('C:\Users\Clay\Documents\MATLAB\startup.m');
disp('To undock figures, try:');
disp('set(0,''DefaultFigureWindowStyle'',''modal'')');
set(0,'DefaultFigureWindowStyle','docked');
set(0,'DefaultTextInterpreter','latex');
set(0,'DefaultTextFontSize',16);
set(0,'DefaultLineLineWidth',2);
@kcmckell
kcmckell / Gather.ini
Last active August 29, 2015 14:01
WinEdt 6 Baller Customizations
// ===============================================================================
// -*- DATA:INI:EDT -*-
//
// WinEdt Gather Data (GDI) Interface
//
// ===============================================================================
[BUILD]
REQUIRES=20080915
@kcmckell
kcmckell / Array_equals.js
Last active August 29, 2015 13:58
Test for equality between Javascrip arrays. Courtesy [Tomas Zato](http://stackoverflow.com/users/607407/tomas-zato) on [Stackoverflow](http://stackoverflow.com/a/14853974).
Array.prototype.equals = function (array) {
// if the other array is a falsy value, return
if (!array)
return false;
// compare lengths - can save a lot of time
if (this.length != array.length)
return false;
for (var i = 0, l=this.length; i < l; i++) {
@kcmckell
kcmckell / .gitconfig
Created April 1, 2014 20:16
Useful git aliases
[alias]
lol = log --oneline --graph --decorate
st = status
ci = commit
ra = !sh git-ra.sh
lola = log --decorate --oneline --graph --all --date-order
lold = !sh -c 'git log --oneline --graph --decorate --left-right --boundary --date-order $1...$2' -
@kcmckell
kcmckell / findAndRemove.js
Last active December 28, 2015 20:49
Find and remove elements that match.
function findAndRemove(superset, subset) {
var ind = 0;
while (superset.length > 0 & subset.length>0 $ len<subset.length) {
var f = superset.indexOf(subset[ind]);
if (f>=0) {
superset=superset.slice(0,f).concat(superset.slice(f+1));
subset=subset.slice(0,ind).concat(subset.slice(ind+1));
} else {
ind++;
}
@kcmckell
kcmckell / ExternalQueryByTeam
Created October 15, 2013 19:50
This Google Spreadsheet function should pull all rows that have Column5 == Team1 and display their Columns 3, 2 and 5 in an external spreadsheet. See the comments below for notes.
=query( importrange( "<source_spreadsheet_key_from_url>", "Form Responses!A:E" ), "select Col3, Col2, Col5 where Col5 contains 'Team1' order by Col2, Col3", 1 )
@kcmckell
kcmckell / createArray
Created October 10, 2013 21:12
Create N-dimensional empty array in JavaScript. Courtesy Matthew Crumley via StackOverflow: http://stackoverflow.com/questions/966225/how-can-i-create-a-two-dimensional-array-in-javascript/966938#966938 Syntax: createArray(); // [] createArray(3,1); // [ [], [], [] ]
function createArray(length) {
var arr = new Array(length || 0),
i = length;
if (arguments.length > 1) {
var args = Array.prototype.slice.call(arguments, 1);
while(i--) arr[length-1 - i] = createArray.apply(this, args);
}
return arr;
};