This file contains 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
def scrape | |
require 'nokogiri' | |
require 'open-uri' | |
# keyword = "nokogiri is my favorite" | |
# domain = "tenderlovemaking.com" | |
keyword = self.text.split.join("+") | |
domain = self.website.url | |
user_agent = get_random_user_agent |
This file contains 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
def triangle(a, b, c) | |
raise TriangleError if a<=0 or b<=0 or c<=0 | |
raise TriangleError if a+b<=c or b+c<=a or a+c<=b | |
return :equilateral if a==b and a==c | |
return :isosceles if a==b or b==c or a==c | |
:scalene | |
end |
This file contains 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
require 'open-uri' | |
require 'nokogiri' | |
zipcode = ARGV[0] || 78705 | |
url = "http://www.weather.com/weather/hourbyhour/graph/#{zipcode}" | |
doc = Nokogiri::HTML(open(url)) | |
raise('Zipcode not found') if /can't find the page you requested/ =~ doc.text | |
hours = doc.css('.hbhWxHour') | |
hours.each do |hour| |
This file contains 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
<%= form_tag registration_index_path do %> | |
<%= fields_for User.new do |u| %> | |
<%= u.label :phone %> | |
<%= u.text_field :phone %> | |
<% end %> | |
<p> | |
<%= label_tag :workout %> | |
<%= check_box_tag :workout %> | |
</p> | |
<p> |
This file contains 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
tail -f log/development.log | grep -vE "(^\s*$|asset)" |
This file contains 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
# Better way to write this? | |
module TopicsHelper | |
def tags_for(topic) | |
tags = "" | |
topic.tags.each do |tag| | |
tags << content_tag(:span, tag.name) | |
end | |
tags.html_safe | |
end |
This file contains 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
<% @posts.each do |post|%> | |
<div id="recentpost"> | |
<%= post.name %><br/><br/> | |
</div> | |
<% end %> |
This file contains 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
def urlToString(url) | |
require 'net/http' | |
uri = URI(url) | |
data = Net::HTTP.get(uri) | |
return data | |
end | |
def writeToFile(image_url) | |
require 'open-uri' | |
file_name = image_url[0][31..48] |
This file contains 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
# navigating to /sitemap.xml for the first time: | |
Start GET "/sitemap.xml" for 127.0.0.1 | |
Processing by SitemapsController#index as XML | |
Post Load (1.2ms) ... | |
Category Load (0.7ms) ... | |
... | |
Renderedsitemaps/index.xml.builder (1231.4ms) | |
Write page /sandbox/public/sitemap.xml (19.5ms) | |
Completed 200 OK in 2301ms (Views: 1523.8ms | ActiveRecord: 31.7ms) |
This file contains 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
upstream unicorn { | |
server unix:/tmp/unicorn.blog.sock fail_timeout=0; | |
} | |
server { | |
listen 80 default deferred; | |
# server_name example.com; | |
root /home/deployer/apps/blog/current/public; | |
location ^~ /assets/ { |
OlderNewer