Skip to content

Instantly share code, notes, and snippets.

View bendavis78's full-sized avatar

Ben Davis bendavis78

  • O'Reilly Media
  • Dallas, TX
View GitHub Profile
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
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
//---- 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,
body, html {
background-color: #EDEDED !important;
}
.intro {
text-align: center;
padding: 13% 0;
margin-bottom: 50px;
}
@bendavis78
bendavis78 / index.html
Created April 12, 2016 15:44
lesson 6 html example
<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">
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
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
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
> JSON.stringify('"hello \n world"\n this & that \r\n')
'"\\"hello \\n world\\"\\n this & that \\r\\n"'
<!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 %>