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
require 'sinatra' | |
require 'redis' | |
require 'json' | |
require 'sanitize' | |
redis = Redis.new | |
get '/' do | |
@index = redis.llen 'messages' | |
erb :index |
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
<script type="text/javascript" src="./jquery/jquery.js"></script> | |
<script type="text/javascript"> | |
function verifyLogin() { | |
$.post('./verify_login.php', | |
{username: $("#username").val(), password: $("#password").val() }, | |
function(output) { | |
if (output == "") { | |
window.location="index.php"; | |
} | |
alert(output); |
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
if top_score = top_hits.map(&:score).max | |
- top_hits.detect { |h| h.score == top_score }.result | |
+ sid = top_hits.detect { |h| h.score == top_score }.stored(:demandbase_sid) | |
+ Company.find_by_demandbase_sid(sid) | |
elsif not options.keys.include?(:country) | |
# There's no location information or no matches based on location | |
# revert to a search with no scope | |
- solr_hits(q, options, nil).first.try(:result) | |
+ sid = solr_hits(q, options, nil).first.stored(:demandbase_sid) | |
+ Company.find_by_demandbase_sid(sid) |
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
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 |
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
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 |
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
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 |
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
require 'sinatra' | |
get '/' do | |
"hello world" | |
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
$('.signin .options ul li').hover(function() { | |
$('.signin .options ul li').removeClass('hover'); | |
$(this).addClass('hover'); | |
}), function() { | |
$('.signin .options ul li').removeClass('hover'); | |
}) |
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
$('.signin .options li').hover( -> | |
$('.signin .options li').removeClass('hover') | |
$(this).addClass('hover') | |
true | |
, -> | |
$('.signin .options li').removeClass('hover') | |
true | |
) |
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
less_encoded = crazy_encoded_stuff.gsub("\\", "") | |
JSON.parse(less_encoded[1, less_encoded.length - 1]) |
OlderNewer