Skip to content

Instantly share code, notes, and snippets.

analytics.load('<?php echo $segmentWriteKey ?>');
function waitUntil(condition, cb, attempt, interval, failure_cb) {
attempt = attempt || 0;
interval = interval || 250;
if (attempt >= 2) {
if (failure_cb) {
failure_cb();
}
return false;
}
@ldrbrandon
ldrbrandon / 0_reuse_code.js
Created June 27, 2016 23:25
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@ldrbrandon
ldrbrandon / gist:6802923
Created October 3, 2013 00:57
DB Drill - AR Student Schema
# Validates attributes
# also has methods that will return a student's full name and age in years
https://github.com/ldrbrandon/ar-student-schema.git
@ldrbrandon
ldrbrandon / gist:6202857
Created August 11, 2013 00:41
RPN calc
class RPNCalculator
def initialize
# new calculator open
end
def evaluate(expression)
# this first part makes the string into an array with everything converted accordingly
tokens = expression.split(' ')
for i in 0..order.length-1
@ldrbrandon
ldrbrandon / gist:6145316
Created August 3, 2013 05:33
Method to calculate mode of a given array
def mode(array)
hash = {}
array.each do |x|
hash[x] += 1 # create a hash with the element as the key and the value increments every time it finds that
# same element again
end
# go through the hash's keys and values and whichever value is highest will be the most frequent
most_freq = []
hash.each do |key,value|
max = 0