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
#!/usr/bin/env ruby | |
require 'rubygems' | |
require 'hpricot' | |
require 'open-uri' | |
query = "//table//table//table//td/font/b" | |
html_doc = Hpricot(open("http://www.ccc.govt.nz/weatherdata/waterweb.htm")).search(query) | |
temperature = html_doc[0].inner_html.to_f |
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
# Came from http://snippets.dzone.com/posts/show/68 | |
require 'rexml/document' | |
require 'net/http' | |
class RSSParser | |
require 'rexml/document' | |
def self.run(url) |
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
class PagesController < ApplicationController | |
def home | |
... | |
@posts = RSSParser.run('http://blog.resolvedigital.com/feed/')[:items] | |
... | |
end | |
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
<div id='blog'> | |
<h2>Fresh off the blog</h2> | |
<h3><%= link_to @posts.first[:title], @posts.first[:link] %></h3> | |
<p> | |
<%= truncate(strip_tags(@posts.first[:encoded]), :length => 285) %> | |
</p> | |
</div> |
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
<div id='blog'> | |
<h2>Latest posts from the blog</h2> | |
<% 3.times do |n| %> | |
<h3> | |
<%= link_to @posts[n][:title], @posts[n][:link] %> | |
</h3> | |
<p> | |
<%= truncate(strip_tags(@posts[n][:encoded]), :length => 285) %> | |
</p> | |
<% 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
= Setup | |
=== In your browser | |
login to http://github.com | |
go to http://github.com/resolve/refinerycms | |
if you have a fork already, delete it (if you're not going to loose work. This makes it much easier for us to integrate your changes back in) | |
click on fork | |
=== In terminal | |
git clone [email protected]:USERNAME/refinerycms.git refinerycms |
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
@interface UIDevice (Utilities) {} | |
+ (BOOL)iPad; | |
@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
/* Use match pattern: * */ | |
#Header, body.chat.with_launchbar div#Header { | |
top: 0px !important; | |
} | |
#launchbar, #corner_logo, #Sidebar, #MainTabs li:nth-last-child(-n+6) { | |
display: none !important; | |
} |
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
class BlogController < ApplicationController | |
def index | |
begin | |
Timeout::timeout(5) { | |
@posts = RSSParser.run('http://refinerycms.com/blog.rss')[:items][0..3] # get the first 3 posts | |
} | |
rescue Timeout::Error => e | |
logger.warn("timeout exceeded for downloading blog RSS: #{e}") | |
@posts = nil | |
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
class TwitterController < ApplicationController | |
around_filter :cache_twitter, :only => [:twitter] | |
def twitter | |
begin | |
Timeout::timeout(5) { | |
result = RSSParser.run(RefinerySetting.find_or_set(:twitter_rss_feed_url, | |
"http://twitter.com/statuses/user_timeline/19258840.rss")) | |
@tweets = result[:items][0..0] if result.present? and result[:items].present? |
OlderNewer