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 / bonus_merge_multiple_arrays.rb
Created May 20, 2020 19:30
Interview Cake Merge Multiple Sorted Arrays question
# In order to win the prize for most cookies sold, my friend Alice and I are going to merge our Girl Scout Cookies orders and enter as one unit.
#
# Each order is represented by an "order id" (an integer).
#
# We have our lists of orders sorted numerically already, in arrays. Write a method to merge our arrays of orders into one sorted array.
#
# For example:
#
# my_array = [3, 4, 6, 10, 11, 15]
# alices_array = [1, 5, 8, 12, 14, 19]
# Intro
Writing changeable code: three different skills
- 1. understand OO design. Code that is easy to change IS well designed.
- 2. skilled at refactoring. Quote from Fowler
--> also maybe insert quote from Kent Beck:
"make the change easy (warning: this may be hard), then make the easy change"
- refactoring is how you morph code to accommodate new requirements. Prefactor vs refactor?
- 3. High value tests!
- Good tests don't need to be changed when you refactor.
@oliverswitzer
oliverswitzer / mixpanel_api.js
Created March 27, 2014 21:14
A node script to get data from mixpanel API and output it to a CSV
// mixpanel_export.js
// node modules
http = require('http');
Mixpanel = require('mixpanel');
md5 = require('MD5');
jsoncsv = require('jsoncsv');
fs = require('fs');
stringify = require('csv-stringify');
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"}
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;
@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
def fibo_finder
if n < 2
n
else
fibo_finder(n-1) + fibo_finder(n-2)
end
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
9.times do |i|
puts i
end
for(var i = 0; i < 10; i++){
console.log(i);
}