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
namespace :attachments do | |
task :migrate_to_s3 => :environment do | |
require 'aws/s3' | |
# Load credentials | |
s3_options = YAML.load_file(File.join(Rails.root, 'config/s3.yml')).symbolize_keys | |
bucket = s3_options[:bucket_name] | |
# Establish S3 connection |
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
# catch all for 404 | |
match '*path', :to => proc { | |
html = File.read(Rails.root.join('public/404.html')) | |
[404, {}, [html]] | |
} |
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
module Crawler | |
class MissSelfridge < Crawler::Base | |
@queue = :crawl | |
def self.perform(url, shop_id) | |
super(url, { | |
:shop_id => shop_id, | |
:crawl => /ProductDisplay|CatalogNavigationSearchResultCmd/, | |
:collect => /ProductDisplay/i, | |
:skip => /refinements|pageSize=200|pageSize=80/i, |
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
# live search | |
match 'live', :to => proc {|env| | |
q = CGI.parse(env['QUERY_STRING'])['q'].to_s | |
json = ActiveSupport::JSON.encode(LiveSearch.query(q)) | |
[200, {}, [json]] | |
} | |
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
# live search | |
match 'live', :to => proc {|env| | |
q = CGI.parse(env['QUERY_STRING'])['q'].to_s | |
results = | |
[200, {}, [LiveSearch.query(q)]] | |
} |
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 NotesController < ApplicationController | |
def create | |
@note = Note.new(params[:note]) | |
if @note.save | |
# attach files | |
params[:note][:file].to_a.each do |file| | |
@note.note_attachments.create(:file => file) | |
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
# HELP! | |
# | |
# I’ve noticed that imagemagick is hogging a large part of the CPU when calling convert and identify, this in turn means I’m getting errors like this: | |
# | |
# Cannot allocate memory – identify -format “%wx%h” “/tmp/._imagename_01bc_030,17721,0.jpg”0 2>/dev/null /usr/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/core_ext/kernel/agnostics.rb:7:in ``’ /usr/lib/ruby/gems/1.8/gems/activesupport-2… | |
# | |
# That error is taken from delayed job. | |
# | |
# Is there any way I can stop imagemagick hogging so much cpu via paperclip or am I destined to grin and bare it? |
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
# For some reason my rails install is looking for gems in the following locations | |
=> Rails 2.3.5 application starting on http://0.0.0.0:3000 | |
Missing these required gems: | |
redis-store | |
You're running: | |
ruby 1.8.7.174 at /usr/local/bin/ruby | |
rubygems 1.3.5 at /Users/jimneath/.gem/ruby/1.8, /usr/local/lib/ruby/gems/1.8 |
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
# I want to turn this: | |
array = [1, 2, 3, 4, 5, 6, 7, 8, 9] | |
# into this: | |
=> [[1, 2, 3], [4, 5, 6], [7, 8, 9]] |
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
#!/bin/sh | |
### BEGIN INIT INFO | |
# Provides: god | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: God | |
### END INIT INFO |