Skip to content

Instantly share code, notes, and snippets.

View oliverswitzer's full-sized avatar
🏠
Working from home

Oliver Switzer oliverswitzer

🏠
Working from home
View GitHub Profile
@oliverswitzer
oliverswitzer / FizzBuzz
Created November 15, 2013 03:12
My FizzBuzz solution!
1.upto(100) do |i|
if i % 3 == 0
puts "fizz"
elsif i % 5 == 0
puts "buzz"
elsif i % 3 == 0 && i % 5 == 0
puts "fizzbuzz"
else
puts i
end
for(var i = 0; i < 10; i++){
console.log(i);
}
9.times do |i|
puts i
end
@oliverswitzer
oliverswitzer / spec_helper.rb
Created December 9, 2013 14:37
rspec helper file
RSpec.configure do |config|
# Use color in STDOUT
config.color_enabled = true
# Use color not only in STDOUT but also in pagers and files
config.tty = true
# Use the specified formatter
config.formatter = :documentation # :progress, :html, :textmate
end
def fibo_finder
if n < 2
n
else
fibo_finder(n-1) + fibo_finder(n-2)
end
end
@oliverswitzer
oliverswitzer / js_practice.js
Created January 20, 2014 21:15
JS Practice
> typeof(3)
'number'
> typeof(3) === typeof(4.32)
true
> 5/0
Infinity
> 3/"bob"
NaN
> NaN === NaN
false
What does the following code evaluate to?
var first_name = function (name) {
return name;
}
first_name("bob");
--> 'bob'
What does the following code evaluate to?
function add(x, y) {
return x + y;
What does the following code print to the console?
var person = {
name: "Joe Camel",
age: 42,
status: "dead"
}
console.log(typeof person);
--> Object {name: "Joe Camel", age: 42, status: "dead"}
@oliverswitzer
oliverswitzer / module.rb
Created February 24, 2014 18:42
An example of a module!
module MyModule
def first_module_method
end
end
@oliverswitzer
oliverswitzer / jQuery.js
Created February 24, 2014 18:48
jQuery example
$('div').on("click", function() {
console.log("I'm a callback function and I'm currently getting called!");
});