Skip to content

Instantly share code, notes, and snippets.

View rvbsanjose's full-sized avatar

Richard Van Breemen rvbsanjose

View GitHub Profile
@rvbsanjose
rvbsanjose / gist:3646322
Created September 5, 2012 22:24
Leap Year in JavaScript
<html>
<head>
<title>Leap Year in JavaScript</title>
<style type="text/css">
* { margin: 0 auto; width: 960px; background-color: blue; }
#text_where {
color: white;
font-weight: bold;
text-align: center;
font-size: 40px;
@rvbsanjose
rvbsanjose / gist:3646245
Created September 5, 2012 22:21
RPN Calculator in JavaScript
<html>
<head>
<title>RPN Calculator</title>
<style type="text/css">
body {
color: white;
background-color: blue;
font-weight: bold;
font-size: 24px;
text-align: center;
@rvbsanjose
rvbsanjose / median.rb
Created August 24, 2012 07:19
Median
def median(array)
sorted_array = array.sort
if array.length % 2 != 0
index = sorted_array.length / 2
median = sorted_array[index]
else
index = sorted_array.length / 2
median = (sorted_array[index].to_f + sorted_array[index-1].to_f) / 2
end
end
@rvbsanjose
rvbsanjose / count_between.rb
Created August 24, 2012 07:10
Count Between
def count_between(array, lower_bound, upper_count)
times = []
until array.size == 0
check_num = array.pop
if check_num.between?(lower_bound, upper_count)
times « check_num
end
end
times.length
end
@rvbsanjose
rvbsanjose / mode.rb
Created August 16, 2012 20:16
calculate the mode of an array
def mode(array)
array.drop_while {|x| array.count(x) < array.count(x + 1) }.select {|x| array.count(x) > 1}.uniq
end