Skip to content

Instantly share code, notes, and snippets.


Dan danneu

  • Texas
View GitHub Profile
View google-scraper.rb
def scrape
require 'nokogiri'
require 'open-uri'
# keyword = "nokogiri is my favorite"
# domain = ""
keyword = self.text.split.join("+")
domain =
user_agent = get_random_user_agent
danneu / ruby_koans_151_solution.rb
Created Aug 4, 2011
Ruby Koans 151 triangle.rb solution
View ruby_koans_151_solution.rb
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
View gist:1428374
require 'open-uri'
require 'nokogiri'
zipcode = ARGV[0] || 78705
url = "{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|
View new.html.erb
<%= form_tag registration_index_path do %>
<%= fields_for do |u| %>
<%= u.label :phone %>
<%= u.text_field :phone %>
<% end %>
<%= label_tag :workout %>
<%= check_box_tag :workout %>
View gist:1683586
tail -f log/development.log | grep -vE "(^\s*$|asset)"
View gist:1750191
# Better way to write this?
module TopicsHelper
def tags_for(topic)
tags = ""
topic.tags.each do |tag|
tags << content_tag(:span,
danneu / home
Created Feb 21, 2012 — forked from anonymous/home
View home
<% @posts.each do |post|%>
<div id="recentpost">
<%= %><br/><br/>
<% end %>
View gist:1897643
def urlToString(url)
require 'net/http'
uri = URI(url)
data = Net::HTTP.get(uri)
return data
def writeToFile(image_url)
require 'open-uri'
file_name = image_url[0][31..48]
View gist:2288102
# navigating to /sitemap.xml for the first time:
Start GET "/sitemap.xml" for
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)
View gist:2357092
upstream unicorn {
server unix:/tmp/ fail_timeout=0;
server {
listen 80 default deferred;
# server_name;
root /home/deployer/apps/blog/current/public;
location ^~ /assets/ {
You can’t perform that action at this time.