Skip to content

Instantly share code, notes, and snippets.

@tim-br
tim-br / Shak-the-dog
Created June 30, 2015 21:06
Shakil the dog work
# Save this file to your computer so you can run it
# via the command line (Terminal) like so:
# $ ruby shakil_the_dog.rb
#
# Your method should wait for user input, which corresponds
# to you saying something to your dog (named Shakil).
# You'll probably want to write other methods, but this
# encapsulates the core dog logic
def shakil_the_dog
# Save this file to your computer so you can run it
# via the command line (Terminal) like so:
# $ ruby shakil_the_dog.rb
#
# Your method should wait for user input, which corresponds
# to you saying something to your dog (named Shakil).
# You'll probably want to write other methods, but this
# encapsulates the core dog logic
def benchmark
# Your benchmarking code goes here.
beginning_time = Time.now
foo = yield
end_time = Time.now
return end_time - beginning_time
end
# Be careful, pasting this into IRB will take a long time to print.
# It's a loooong string. :)
### SETUP
require 'rspec'
RSpec.configure do |config|
config.color = true
end
### LOGIC (fix me)
# Returns the average of all the numbers in the array
require 'rspec'
module Flight
def fly
puts "I am a #{self.class} and I am flying"
end
end
class Animal
def warm_blooded?
EXERCISE 1/2 are earlier versions of ex 3
EXERCISE 3.
select books.title, stock.retail, stock.stock, books.id AS BOOK_ID, editions.isbn, editions.publisher_id from books left join editions on books.id = editions.book_id left join stock on stock.isbn = editions.isbn where editions.publisher_id = 59;
EXERCISE 4.
select books.title, stock.retail, stock.stock, books.id AS BOOK_ID, editions.isbn, editions.publisher_id from books left join editions on books.id = editions.book_id left join stock on stock.isbn = editions.isbn where editions.publisher_id = 59 and stock.stock > 0;
@tim-br
tim-br / set_functions.hs
Created August 2, 2015 17:40
set functions from sicp for haskell
intersection_set _ [] = []
intersection_set [] _ = []
intersection_set (x:xs) ys
| element_of_set x ys = x : intersection_set xs ys
| otherwise = intersection_set xs ys
element_of_set _ [] = False
element_of_set x (y:ys)
| x == y = True
| otherwise = element_of_set x ys
function arrayOfLight(x){
res = []
for(i = 0; i <= x; i++){
res.push(i);
}
return res;
}
data MyVector a = XY a a deriving (Show)
xcord :: (Num a) => MyVector a -> a
xcord (XY a _) = a
ycord :: (Num a) => MyVector a -> a
ycord (XY _ a) = a
subVect :: (Num a) => MyVector a -> MyVector a -> MyVector a
subVect (XY x1 y1) (XY x2 y2) = XY (x1 - x2) (y1 - y2)
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
<meta charset="utf-8">
<title>Simple markers</title>
<style>
html, body, #map-canvas {
height: 100%;
margin: 0;