Skip to content

Instantly share code, notes, and snippets.

@BooneTeam
BooneTeam / grades_and_sort.rb
Created July 10, 2013 23:08
Calculates grades and can sort students based on any field.
Struct.new("Student", :scores, :first_name, :last_name, :ssn)
class AverageScores
attr_accessor :scores
def initialize(scores)
@scores = scores
end
@BooneTeam
BooneTeam / github.js
Last active December 19, 2015 13:19
Github Functionality for DBConnect This Allows a user to drag their top five Github repositories urls and display them.
repos = [];
$(document).ready(function(){
$('#git_error').hide();
$.each($( "#github_list_showing tr td"),function(index,value){
repos.push($(value).data());
});
$( ".all_repos tr" ).draggable({helper: 'clone'});
$( "#github_list_showing" ).droppable({
@BooneTeam
BooneTeam / arrays.rb
Created July 9, 2013 12:27
Creating my own enumerable methods in ruby
=begin
Array#each
calls a block for each item in an array
Array#map
calls a block for each item in an array and returns a new array based on this block
Array#inject
Takes an argument and calls a block for each item in an array. The argument value is manipulated
@BooneTeam
BooneTeam / benchmark_fib.rb
Created July 9, 2013 01:15
Benchmark Fibonacci iterative and recursive
require 'Benchmark'
def fibonacci_iterative(n)
return 0 if n == 0
vals = [0,1]
(n-1).times do
vals << vals[-1]+vals[-2]
end
vals.last
end
@BooneTeam
BooneTeam / binary.rb
Created July 9, 2013 01:04
binary search
# This will find the center_point
def binary_search(num, arr)
low = 0
high = arr.length - 1
while (low <= high)
i = ((low+high)/2).floor
if arr[i] < num
low = i+1
@BooneTeam
BooneTeam / largest_product.rb
Created July 9, 2013 00:26
largest product in a series computed recursively and iteratively
class LargestProduct
attr_accessor :series
def initialize(series)
@series = series
end
def split_series
series.split("").map {|num| num.to_i }
@BooneTeam
BooneTeam / gist:5922180
Last active December 19, 2015 07:59
Prime Factors Recursive
def primes(x, factors = [], y=2)
return factors if y > x
if x % y == 0
factors << y
x /= y
else
y +=1
end
primes(x,factors,y)
end
@BooneTeam
BooneTeam / factorial_recursion.rb
Created July 3, 2013 18:51
Recursive Factorial Solution
def factorial_recursion(n, factorial = 1)
return factorial if n == 1
factorial *= (n)
factorial(n-1, factorial)
end
puts factorial_recursion(5)
#Run it at CodePad.org
//------------------------------------------------------------------------------------------------------------------
// YOUR CODE: Create your Zoo "object literal" and Animal "constructor" and "prototypes" here.
//------------------------------------------------------------------------------------------------------------------
//------------------------------------------------------------------------------------------------------------------
// DRIVER CODE: Do **NOT** change anything below this point. Your task is to implement code above to make this work.
//------------------------------------------------------------------------------------------------------------------
@BooneTeam
BooneTeam / index.html
Last active December 17, 2015 15:59 — forked from dbc-challenges/index.html
DBC Phase 2 Practice Assessment Part 3
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="http://cdn.jsdelivr.net/normalize/2.1.0/normalize.css">
<link rel="stylesheet" href="main.css">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:300,400,600,700,800">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Lato:100,900">
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/font-awesome/3.0.2/css/font-awesome.min.css">
</head>