Skip to content

Instantly share code, notes, and snippets.

View holtbp's full-sized avatar
💻
We're hiring!

Brett Holt holtbp

💻
We're hiring!
View GitHub Profile
@holtbp
holtbp / outputJSONlist.js
Created March 27, 2012 23:28
Output AJAX response into UL on page
//jQuery.ajax - Success, error and complete are deprecated in jQuery 1.8
function toListItem(element) {
return '<li>' + element + '</li>';
}
var first = $.ajax({
type: "GET",
url: "/items",
accepts: "text/json"
});
@holtbp
holtbp / duplicate2.js
Created March 22, 2012 01:05
Duplicate Array without Assignment
// Given an array, var arr = [1,2,3,4,5] how do you implement a function duplicator such that
// arr.duplicator() == [1,2,3,4,5,1,2,3,4,5]?
// Duplicate array elements by modifying array instead of assigning the returned array to a new var.
Array.prototype.duplicator = function(obj) {
this.map(duplicate);
};
function duplicate(element, index, array){
return array.push(element);
@holtbp
holtbp / duplicator.js
Created March 22, 2012 00:35
Duplicating an Array
// Given an array, var arr = [1,2,3,4,5] how do you implement a function duplicator such that
// arr.duplicator() == [1,2,3,4,5,1,2,3,4,5]?
Array.prototype.duplicator = function() {
return this.concat(this);
};
var arr = [1,2,3,4,5],
dupe = arr.duplicator();
@holtbp
holtbp / tripleArrElements.js
Created March 21, 2012 18:36
Array Elements Triple and Join
// Given an array ["foo", "bar", "baz"],
// return ["foo foo foo", "bar bar bar", "baz baz baz"]
var arr = ["foo", "bar", "baz"];
function triple(element) {
return [element, element, element].join(" ");
}
arr.forEach(function() {
@holtbp
holtbp / cacheMusic.py
Created September 26, 2011 19:30
Turntable FM Cache File type converter
import os, glob, shutil, sys
path = os.environ['LOCALAPPDATA'] + "/Google/Chrome/User Data/Default/Cache/"
listing = os.listdir(path)
for infile in listing:
if "f_" in infile:
abs_path = path + infile
statinfo = os.stat(abs_path)
if statinfo.st_size > 1000000: #checking to see if the file > 1MB