Skip to content

Instantly share code, notes, and snippets.

View BrooksPatton's full-sized avatar

Brooks Patton BrooksPatton

View GitHub Profile
@BrooksPatton
BrooksPatton / quicksort.js
Created November 7, 2016 07:14
Quick Sort - javascript
// this gist assumes lodash or underscore is installed in order to shuffle the array for testing purposes
function quickSort (arr) {
console.info('step: ', arr);
if(arr.length <= 1) return arr;
// find middle point of array
var swapPosition = Math.floor((arr.length -1) / 2);
var swapValue = arr.splice(swapPosition, 1)
var left = [];
@BrooksPatton
BrooksPatton / double_for_breakout.js
Created September 9, 2016 02:04
Breaking out of nested for loops
/*
When you break out of a nested for loop do you break out of both loops? Or just the inner one?
If you want to run this, you will need the colors npm module.
*/
const colors = require(`colors`)
for(let i = 0; i < 10; i++) {
console.log(`i: ${i}`.green);
@BrooksPatton
BrooksPatton / terminal-bash-zip.txt
Created October 17, 2015 17:50
Bash command to zip up a directory with everything in it.
zip ../filename.zip -r * .[^.]*