This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :scraper do | |
task scrape: :environment do | |
# the url we want to scrape | |
url = "http://www.amazon.com/s/ref=lp_2619525011_nr_n_5?fst=as%3Aoff&rh=n%3A2619525011%2Cn%3A%212619526011%2Cn%3A2686328011&bbn=2619526011&ie=UTF8&qid=1462292509&rnid=2619526011" | |
# get the raw HTML content | |
response = HTTParty.get url | |
html = response.body | |
# get the root document so we can parse it using CSS selectors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace :scraper do | |
task scrape: :environment do | |
# the url we want to scrape | |
url = "http://www.amazon.com/s/ref=lp_2619525011_nr_n_5?fst=as%3Aoff&rh=n%3A2619525011%2Cn%3A%212619526011%2Cn%3A2686328011&bbn=2619526011&ie=UTF8&qid=1462292509&rnid=2619526011" | |
# get the raw HTML content | |
response = HTTParty.get url | |
html = response.body | |
# get the root document so we can parse it using CSS selectors |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//---- Game utility functions ------------------- | |
function getBounds(id) { | |
var x = getXPosition(id); | |
var y = getYPosition(id); | |
var w = parseInt(getAttribute(id, "width")); | |
var h = parseInt(getAttribute(id, "height")); | |
return { | |
left: x, | |
top: y, | |
right: x + w, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body, html { | |
background-color: #EDEDED !important; | |
} | |
.intro { | |
text-align: center; | |
padding: 13% 0; | |
margin-bottom: 50px; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Materialize CSS Framework Demo</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"/> | |
<link type="text/css" rel="stylesheet" href="bower_components/Materialize/dist/css/materialize.min.css" media="screen,projection"/> | |
<link type="text/css" rel="stylesheet" href="style.css"> | |
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class OriginPokemon | |
# Create a strength attribute that can be accessed on all instances | |
attr_accessor :strength | |
# `initialize` is our constructor method | |
def initialize | |
# Set strength to a default value of 100. | |
@strength = 100.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Person | |
attr_accessor :first_name, :last_name, :gender, :age | |
def initialize(first_name, last_name, gender, age) | |
@first_name = first_name | |
@last_name = last_name | |
@gender = gender | |
@age = age | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
max = 20 | |
number = rand(max) | |
puts "I'm thinking of a number between 1 and #{max}. Guess." | |
begin | |
answer = gets.to_i | |
difference = number - answer | |
byebug | |
if difference.abs < 3 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> JSON.stringify('"hello \n world"\n this & that \r\n') | |
'"\\"hello \\n world\\"\\n this & that \\r\\n"' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>Musicdb</title> | |
<%= stylesheet_link_tag "application", :media => "all" %> | |
<%= stylesheet_link_tag "https://fonts.googleapis.com/icon?family=Material+Icons" %> | |
<%= javascript_include_tag "application" %> | |
<%= csrf_meta_tags %> |