Skip to content

Instantly share code, notes, and snippets.

View vanstee's full-sized avatar
💭
🛠

Patrick Van Stee vanstee

💭
🛠
View GitHub Profile
def reindex_companies_since(timestamp)
conditions = ["updated_at >= ?", timestamp]
total = Company.count(:conditions => conditions)
indexed = 0
companies = Queue.new
indexing = true
Thread.abort_on_exception = true
def self.build_fuzzy_query(name, options = {})
[].tap do |q|
subq = [].tap do |subq|
Normalizer.short_name(name).split.uniq.each do |token|
subq << "short_name_text:#{token}^5" # exact match
subq << "short_name_text:#{token}~^3" # fuzzy match
subq << "marketing_alias_text:#{token}^5" # exact match
subq << "marketing_alias_text:#{token}~^3" # fuzzy match
end
setup do
@company = Factory(:company, :company_name => "Highgroove Studios", :marketing_alias => "Genius Wolf Brains", :state => "GA")
@top = Factory(:company, :company_name => "Company HQ", :state => "GA", :company_search_weight => '1', :company_sort_order => '5')
@middle = Factory(:company, :company_name => "Company", :state => "GA", :company_search_weight => '1', :company_sort_order => '5')
@bottom = Factory(:company, :company_name => "Company", :state => "GA", :company_search_weight => '5', :company_sort_order => '1')
Company.solr_index_batch!({})
end
require 'sinatra'
get '/' do
"hello world"
end
$('.signin .options ul li').hover(function() {
$('.signin .options ul li').removeClass('hover');
$(this).addClass('hover');
}), function() {
$('.signin .options ul li').removeClass('hover');
})
$('.signin .options li').hover( ->
$('.signin .options li').removeClass('hover')
$(this).addClass('hover')
true
, ->
$('.signin .options li').removeClass('hover')
true
)
less_encoded = crazy_encoded_stuff.gsub("\\", "")
JSON.parse(less_encoded[1, less_encoded.length - 1])
require 'blather/client'
setup 'hello@highgroove.com', '******', 'talk.google.com'
message :chat?, :body do |m|
write_to_stream "I am a robot!"
end
class EventsController < AdminController
def index
@days_with_events = Events.all.map(&:to_days).flatten.uniq
end
end
class Event < ActiveRecord::Base
def to_days
(started_at.to_date..ended_at.to_date).to_a
end
....
requirements = scoped_requirements_for_index_or_export.page(page).per(params[:per_page]).all
requirements.map(&:id) #apparently makes this work....
logger.debug "DEBUG: Requirement: #{@requirement.id}"
logger.debug "DEBUG: Last Requirement: #{requirements.last.id}"
if requirements.last.id == @requirement.id and requirements.num_pages != page
....