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 / 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
@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 / 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 / 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 / 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 / turntableExperiment.js
Created April 2, 2012 20:56
Turntable (In Progress) - Attempt to make a closure without using the TTFM API
ttfm = {
awesome: null,
lame: null,
setButtons: function() {
var awesome, lame;
$('div.roomView > div > a').each(function() {
if ($(this).css('top') === '555px') {
if ($(this).css('left') === '370px') {
this.awesome = $(this);
} else {
@holtbp
holtbp / .githelpers
Last active September 27, 2016 20:50
Git Helpers
#!/bin/bash
# Original by Gary Bernhardt:
#
# https://raw.github.com/garybernhardt/dotfiles/master/.githelpers
#
# Log output:
#
# 51c333e 2012-07-12 Gary Bernhardt add vim-eunuch
#
@holtbp
holtbp / Installation.md
Last active January 28, 2017 08:04
Getting Started with Elixir & Phoenix

Install

This install guide was written for Mac OS X, and Homebrew is required.

If you do not have Homebrew installed, you will find instructions here.

If you do have Homebrew installed, you will want to update it, just in case:

$ brew update
@holtbp
holtbp / BuildingPhoenixAPI.md
Last active June 26, 2023 18:01
Build and test Phoenix JSON API

Build and test a blazing fast JSON API with Phoenix, an Elixir framework

Original Post

Note: This guide was written for Phoenix 1.1.4. Parts of it may no longer work if you are using a newer version.

Let’s build a JSON API that serves a list of contacts. We’ll be writing it using Elixir (version 1.2.5) and Phoenix (version 1.1.4). Phoenix is a framework written in Elixir that aims to make writing fast, low latency web applications as enjoyable as possible.

Source Code: The source code after finishing this guide can be found here.

@holtbp
holtbp / setup.md
Last active June 27, 2018 06:04
Ejabberd + Riak on Mac OS X

Install ejabberd

Started out by following the instructions here for installing ejabberd on my Mac.

Configure and make:

## Enable flags ensure modules are included to support Riak and Redis
./configure --enable-riak --enable-redis --prefix=$HOME/my-ejabberd
./rebar get-deps
./rebar compile