Skip to content

Instantly share code, notes, and snippets.

View jimneath's full-sized avatar

Jim Neath jimneath

View GitHub Profile
class Admin::JobsController < ApplicationController
layout 'admin'
moderation_fu :model => Job
before_filter :admin_required
def index
@jobs = Job.paginate(:page => params[:page])
end
def show
class Admin::JobsController < ApplicationController
layout 'admin'
moderation_fu :model => Job
before_filter :admin_required
def index
@jobs = Job.paginate(:page => params[:page])
end
def show
#!/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
# 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]]
# 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
# 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?
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
# live search
match 'live', :to => proc {|env|
q = CGI.parse(env['QUERY_STRING'])['q'].to_s
results =
[200, {}, [LiveSearch.query(q)]]
}
# 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]]
}
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,