Skip to content

Instantly share code, notes, and snippets.

def process_url(url, download_directory, pages)
doc = Nokogiri::HTML(open(url))
doc.css('.thing.link').each do |entry|
id = entry['data-fullname']
link = entry.css('a.title')[0]
next unless link
title = link.content
if title =~ /(\d{3,5})\s?x\s?(\d{3,5})/
width, height = $1.to_i, $2.to_i
@gotmayonase
gotmayonase / gist:7360783
Created November 7, 2013 19:50
Add Depth to the Web
var d = document.createElement('div');
d.innerHTML = "\
<style>\
*:not(.icon):not(i), *:not(.icon):not(i):after, *:not(.icon):not(i):before {\
box-shadow: 0px 0px 4px 0px #000 !important;\
text-shadow: 1px 1px 3px #fff !important;\
}\
body { \
background-image: url(http://meepletown.com/wp-content/uploads/2012/07/depth.jpg) !important;\
} \
class DisableAssetsLogger
def initialize(app)
@app = app
Rails.application.assets.logger = Logger.new('/dev/null')
end
def call(env)
previous_level = Rails.logger.level
Rails.logger.level = Logger::ERROR if env['PATH_INFO'].index("/assets/") == 0
@app.call(env)
#!/usr/bin/env ruby
require 'rmagick'
include Magick
[".jpg", ".png", ".gif"].each do |image_extension|
`mkdir -p ./left`
`mkdir -p ./right`
module Delayed
module Plugins
class Airbrake < Plugin
callbacks do |lifecycle|
lifecycle.after(:failure) do |worker, job|
backtrace = job.last_error.split("\n")
::Airbrake.notify_or_ignore(
:error_class => "Failed Delayed Job",
:error_message => backtrace.shift,
@gotmayonase
gotmayonase / lochness.rb
Created March 7, 2012 21:26 — forked from marcinbunsch/lochness.rb
Loch Ness Monster Case implementation in Ruby
class String
def loch_ness_monster_case
self.split('::').collect do |section|
section.gsub(/([^\/])([A-Z])/, '\1_\2').downcase.split(/_/).collect { |part|
chars = part.split('')
half = chars.length/2
chars[half].upcase!
chars[half - 1].upcase!
chars.join('')
thread = Thread.new {
Guard.start(:notify => true)
}
@gotmayonase
gotmayonase / gist:1823449
Created February 14, 2012 04:01
Name ideas for a site to help cyclists find local group rides
localpeloton.com
pelocalton.com
paceliners.com
velogroups.com
@gotmayonase
gotmayonase / JsonRenderer.rb
Created February 11, 2012 21:42
A link renderer for WillPaginate that converts your pagination to a hash for rendering in Json
class JsonRenderer < WillPaginate::ViewHelpers::LinkRendererBase
def prepare(collection, options, context)
super(collection, options)
@context = context
end
def to_json
{
:next_page => url(next_page),
@gotmayonase
gotmayonase / JsonRenderer
Created February 11, 2012 21:41
A link renderer for WillPaginate that converts your pagination to a hash for rendering in Json
class JsonRenderer < WillPaginate::ViewHelpers::LinkRendererBase
def prepare(collection, options, context)
super(collection, options)
@context = context
end
def to_json
{
:next_page => url(next_page),