Skip to content

Instantly share code, notes, and snippets.

View hammeiam's full-sized avatar

David Hamme hammeiam

  • San Francisco, CA
View GitHub Profile
# Love running tests but hate having to check and see if they're finished?
# Add rspek to your .bash_profile to get a desktop notification (plus optional sound) when your tests are done!
# Before using, make sure to grab the dependency with `brew install terminal-notifier` or `gem install terminal-notifier`
#
# USE:
# rspek -f // run all tests in /spec. `--fail-fast` is set by default, `-f` disables it
# rspek /spec/features -q // run all features, no audio notification
# rspek some_file_spec.rb:50 // run one test
function rspek() {
### Quick Diff
### A bash function that lets you see a diff without tabbing through all of your project folders
###
### Imagine you changed some number of files in your project and wanted to view the git diff of one of them
### but your project is deepy nested, so you have to type in the first letters and tab through each folder
### eg: folder_a/folder_b/folder_c/folder_d/my_file.js
###
### Instead of doing all that, just use `$ qdif my_file` to search your modified folders and show a diff of the first result
function qdif() {
@hammeiam
hammeiam / inPlaceFlatten.js
Last active August 29, 2015 14:15
A simple implementation of an in-place flatten function in javascript
function inPlaceFlatten(arr){
for (var i = 0; i < arr.length; i++) {
if(arr[i] instanceof Array){
var temp = inPlaceFlatten(arr[i]);
arr = arr.slice(0, i).concat(temp, arr.slice(i + 1));
i += temp.length - 1;
}
};
return arr;
}
@hammeiam
hammeiam / flatten.js
Last active August 29, 2015 14:15
A simple implementation of flatten in javascript
function flatten(arr){
var output = [];
for (var i = 0; i < arr.length; i++) {
if(arr[i] instanceof Array){
output = output.concat(flatten(arr[i]))
} else {
output.push(arr[i]);
}
};
return output;