Skip to content

Instantly share code, notes, and snippets.

View mrmemes-eth's full-sized avatar
⚗️
creating

Stephen Caudill mrmemes-eth

⚗️
creating
View GitHub Profile
(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)))]
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
@mrmemes-eth
mrmemes-eth / attached_file.rb
Created May 17, 2011 20:44 — forked from jens/attached_file.rb
Duplicate items when using update_attributes and decent_exposure
class AttachedFile < ActiveRecord::Base
belongs_to :parent, :polymorphic => true
end
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)
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