Skip to content

Instantly share code, notes, and snippets.

Stephen Caudill voxdolo

View GitHub Profile
View gist:4211367
(ns hackerfews.core
2 (:require [net.cgrand.enlive-html :as html]))
3
4 (def url (java.net.URI. "http://news.ycombinator.com/"))
5
6 (defn titles
7 [docx] (flatten (map :content (html/select docx [:td.title :a]))))
8
9 (defn numbers-in-nodes
10 [docx selector] (let [x (flatten (map :content (html/select docx selector)))]
View view_helpers.rb
module ClearEyes
module ViewHelpers
def self.included(base)
base.send(:attr_accessor, :image, :options)
end
def r_image( pixel_ratio )
insert_on = -File.extname(self.image).size-1
image_tag(self.image.insert(insert_on, "@#{pixel_ratio}x"), self.options)
end
@voxdolo
voxdolo / attached_file.rb
Created May 17, 2011 — forked from jens/attached_file.rb
Duplicate items when using update_attributes and decent_exposure
View attached_file.rb
class AttachedFile < ActiveRecord::Base
belongs_to :parent, :polymorphic => true
end
View things_controller.rb
class ThingsController < ApplicationController
respond_to :html, :json
# decent_exposure won't currently intuit a collection (plural resource) for you. The SLTD error is
# caused by a circular reference between an undeclared collection (which the singular resource attempts
# to scope from) and the singular resource. To fix this problem, just define the collection:
expose(:things) { Thing.all }
# or alternatively, something like:
# expose(:things) { current_user.things }
expose(:thing)
View gist:407082
def wait_conditionally_until
if page.driver.wait?
page.wait_until do
begin
yield
rescue Selenium::WebDriver::Error::WebDriverError => e
# do nothing - continue to wait for timeout
end
end
else
You can’t perform that action at this time.