Skip to content

Instantly share code, notes, and snippets.

View martinlaws's full-sized avatar

Martin Laws martinlaws

View GitHub Profile
@martinlaws
martinlaws / candidates.rb
Last active October 23, 2015 02:20
Searches and sorts job candidates based on age, years of experience, github points, programming languages, the date applied and the candidate's age
require 'active_support/all'
@candidates = [
{
id: 5,
years_of_experience: 4,
github_points: 293,
languages: ['C', 'Ruby', 'Python', 'Clojure'],
date_applied: 5.days.ago.to_date,
age: 26
@martinlaws
martinlaws / 1_hello_world.rb
Created October 25, 2015 01:30
rspec exercises - lhl wk1e
### SETUP
require 'rspec'
### LOGIC (fix me)
def hello(who)
"hello #{who}!"
end
### TEST CODE (don't touch me)
def letter_count(string)
counting = Hash.new(0)
indexing = Hash.new { |hash, key| hash[key] = [] }
string.split('').each_with_index do |letter, index|
next if letter == ' '
counting[letter] += 1
indexing[letter] << index
end
puts counting
puts indexing
# Define 8 empty classes: Animal, Mammal, Amphibian, Primate, Frog, Bat, Parrot, and Chimpanzee.
class Animal
attr_reader :num_legs
def warm_blooded?
@warm_blooded
end
end
module Flight
attr_reader :speed
-- Exercise 1
SELECT book_id
FROM editions
WHERE publisher_id = 59;
-- Excercise 2
SELECT b.id, b.title, e.book_id
FROM books AS b, editions AS e
-- Exercise 1
SELECT book_id
FROM editions
WHERE publisher_id = 59;
-- Excercise 2
SELECT b.id, b.title, e.book_id
FROM books AS b, editions AS e
var myArray = []
var i = 0
var arrayOfLight = function(x) {
while(i < x + 1) {
myArray.push(i)
i++;
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
</head>
<body>
<h1>Welcome to the <em>Fancy Betting Game</em>!</h1>
<p id='wallet'></p>
@martinlaws
martinlaws / README.md
Created August 3, 2016 22:20 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@martinlaws
martinlaws / 0_lecture_notes.md
Created August 22, 2016 20:53 — forked from fzero/0_lecture_notes.md
LighthouseLabs - W6D1 Breakout - JS + DOM intro

Javascript in the browser!

  • window, navigator
    • BOM - Browser Object Model
      • navigator represents the the browser basic code (or kernel) and properties, like version, user agent string, language, geolocation options and so on.
      • window is a "god object" containing all browser components, such as the address bar (window.location), modal dialogues (alert(), prompt()) and the window being displayed on screen itself. It's also the top object where all global variables are assigned to.
  • document
    • DOM - Document Object Model
    • Contains all of the content being displayed - in other words, whatever is inside the window.
  • The document represents all content as nodes - tags, text, images, and so on.