FridayHug.com http://fridayhug.com
The Smallest Rails App http://thesmallestrailsapp.com
%w(action_controller/railtie coderay).each &method(:require)| # This is a skeleton for testing models including examples of validations, callbacks, | |
| # scopes, instance & class methods, associations, and more. | |
| # Pick and choose what you want, as all models don't NEED to be tested at this depth. | |
| # | |
| # I'm always eager to hear new tips & suggestions as I'm still new to testing, | |
| # so if you have any, please share! | |
| # | |
| # This skeleton also assumes you're using the following gems: | |
| # | |
| # rspec-rails: https://github.com/rspec/rspec-rails |
| # http://nokogiri.org/Nokogiri/XML/Node.html#method-i-css | |
| require 'mechanize' | |
| require 'csv' | |
| puts "Product Scraper!!!" | |
| puts ' ' | |
| urls = [ | |
| "http://www.zappos.com/seavees-teva-universal-sandal-concrete", |
| class TweetsController < ApplicationController | |
| before_action :create_client | |
| def index | |
| batch_size = 10 | |
| @twitter_handle = "dhh" | |
| @tweets = @client.user_timeline(@twitter_handle).take(batch_size) | |
| @friends = @client.friends(@twitter_handle).take(batch_size) |
| # http://ruby-doc.org/stdlib-2.0.0/libdoc/open-uri/rdoc/OpenURI.html | |
| require 'open-uri' | |
| # Go fetch the contents of a URL & store them as a String | |
| response = open('http://www.example.com').read | |
| # "Pretty prints" the result to look like a web page instead of one long string of HTML | |
| URI.parse(response).class | |
| # Print the contents of the website to the console |
| require 'mechanize' | |
| require 'csv' | |
| # Load up the trending Ruby repos on GitHub from the last month. | |
| url_to_scrape = "https://github.com/trending?l=ruby&since=monthly" | |
| # Snag the website with Mechanize & parse it into an XML document we can query. | |
| page = Mechanize.new.get(url_to_scrape) | |
| # Set the name of the CSV we'll create & load from. | |
| file = "repo_data.csv" |
| # http://ruby-doc.org/stdlib-2.0.0/libdoc/open-uri/rdoc/OpenURI.html | |
| require 'open-uri' | |
| # https://github.com/flori/json | |
| require 'json' | |
| # http://stackoverflow.com/questions/9008847/what-is-difference-between-p-and-pp | |
| require 'pp' | |
| # Construct the URL we'll be calling | |
| request_uri = 'http://localhost:3000/users.json' | |
| request_query = '' |
| # Gem that wraps around the Gist API | |
| # https://github.com/sinisterchipmunk/active-gist | |
| require 'activegist' | |
| # GitHub Gist API documentation: | |
| # - http://developer.github.com/v3/gists/ | |
| # Set up credentials. | |
| ActiveGist::API.username = "Your GitHub username" | |
| ActiveGist::API.password = "Your GitHub password" |
| # http://www.ruby-doc.org/stdlib-2.0/libdoc/benchmark/rdoc/Benchmark.html | |
| require 'benchmark' | |
| # http://www.ruby-doc.org/stdlib-2.0.0/libdoc/bigdecimal/rdoc/BigMath.html | |
| require 'bigdecimal/math' | |
| # Set the number of iterations to run. The underscore here is used as a substitute for normal comma so Ruby interprets the number correctly. | |
| iterations = 10 | |
| puts "\nCalculating pi #{iterations} times.\n\n" |
| " Vim color file | |
| " Converted from Textmate theme Monokai Refined using Coloration v0.3.2 (http://github.com/sickill/coloration) | |
| set background=dark | |
| " highlight clear | |
| highlight Normal guibg=black guifg=white | |
| if exists("syntax_on") | |
| syntax reset | |
| endif |
FridayHug.com http://fridayhug.com
The Smallest Rails App http://thesmallestrailsapp.com
%w(action_controller/railtie coderay).each &method(:require)