Skip to content

Instantly share code, notes, and snippets.

@apolzon
apolzon / gist:2354749
Created April 10, 2012 21:35
olark configuration.js
= javascript_include_tag "external/olark.onready"
:javascript
$(document).ready(function(){
if (typeof(olark) !== "undefined") {
olark.identify('5955-991-10-7137');
olark("api.visitor.updateFullName", {fullName: "#{current_user.first_name} #{current_user.last_name}"});
olark("api.visitor.updateEmailAddress", {emailAddress: "#{current_user.email}"});
olark('api.chat.updateVisitorNickname', {snippet: "MY AWESOME CUSTOM NICK", hidesDefault: true});
}
});
nav_tabs.each do |tab_name, (tab_info1, tab_info2, tab_info3)|
end
SELECT core_agent_id, agents.*, total_sales_rank, total_sales_count, city_sales_rank, city_sales_count, ((10*total_sales_rank + 15*city_sales_rank)/cast(25 as float) * 100) as hl_score FROM (SELECT agents.*, agents.id as core_agent_id, percent_rank() over (order by coalesce(sum(agent_metrics.actual_sold_transactions), 0) asc) as total_sales_rank, coalesce(sum(agent_metrics.actual_sold_transactions), 0) as total_sales_count, percent_rank() over (order by coalesce(sum(agent_city_metrics.actual_sold_transactions), 0) asc) as city_sales_rank, coalesce(sum(agent_city_metrics.actual_sold_transactions), 0) as city_sales_count FROM "agents" LEFT OUTER JOIN agent_metrics
ON agent_metrics.agent_id = agents.id
AND agent_metrics.acting_for = 'buyer' LEFT OUTER JOIN agent_city_metrics
ON agent_city_metrics.agent_id = agents.id
AND agent_city_metrics.city_id = 220
AND agent_city_metrics.acting_for = 'buyer' GROUP BY agents.id) scores, agents WHERE (agents.id = core_agent_id) ORDER BY hl_score desc LIMIT 15
@apolzon
apolzon / gist:2998700
Created June 26, 2012 20:25
Production Search -- 9875ms
SELECT agent_id,
total_sales_rank,
total_sales_count,
city_sales_rank,
city_sales_count,
((10*total_sales_rank + 15*city_sales_rank)/cast(25 as float) * 100) as hl_score
FROM (
SELECT agents.id as agent_id,
percent_rank() over (order by coalesce(sum(agent_metrics.actual_sold_transactions), 0) asc) as total_sales_rank,
coalesce(sum(agent_metrics.actual_sold_transactions), 0) as total_sales_count,
@apolzon
apolzon / gist:2998701
Created June 26, 2012 20:26
Production Search -- 26016ms
SELECT scores.*,
((10*total_sales_rank + 15*city_sales_rank)/cast(25 as float) * 100) as hl_score
FROM (
SELECT agents.*,
percent_rank() over (order by coalesce(sum(agent_metrics.actual_sold_transactions), 0) asc) as total_sales_rank,
coalesce(sum(agent_metrics.actual_sold_transactions), 0) as total_sales_count,
percent_rank() over (order by coalesce(sum(agent_city_metrics.actual_sold_transactions), 0) asc) as city_sales_rank,
coalesce(sum(agent_city_metrics.actual_sold_transactions), 0) as city_sales_count
FROM "agents"
LEFT OUTER JOIN agent_metrics
@apolzon
apolzon / gist:3147201
Created July 19, 2012 22:06
Empty City Names
[",", "1", "11/", "1167del Mar", "3", "30157", "33710", "35419 Willow Circle", "430", "531", "595", "62500", "8clearwater", "91911", "92021el Cajon", "92028", "92029", "92129", "Abbevi", "Abingdon", "Acampo", "Achula Vista", "Acton", "Adairs", "Adamsville", "Adrian", "Adult Village", "Agness", "Ahens", "Airepka", "Albert City", "Albuquerque", "Algoa", "Algona", "Alipine", "Allen", "Alma", "Alpiine", "Alpine Meadows", "Alpline", "Alston", "Alta", "Altamone Springs", "Alvaton", "Ambrose", "Ames", "Anahauc", "Anahuc", "Anchor Bay", "Andice", "Annetta", "Annetta North", "Antelope", "Antony", "Anuhuac", "Apolloa Beach", "Apopka, Florida", "Applegate", "Applin", "Appollo Beach", "Appolo Beach", "Arcade", "Arcolarosharon", "Ardsley-on-hudson", "Arnold", "Arondsville", "Atlant", "Atlant", "Atnens", "Attapu", "Atthens", "August", "Auma Valley", "Austin", "Austin", "Ava", "Avera", "Avon City", "Avonda", "Avondale", "Avondale Estate", "Axson", "Ballgr", "Ballico", "Bangall", "Banta", "Barbers Hill", "Baycliff", "Bay Har
@apolzon
apolzon / gist:3147207
Created July 19, 2012 22:07
Empty City IDS
[3, 7, 11, 13, 22, 26, 36, 39, 40, 43, 125, 155, 170, 197, 204, 207, 236, 242, 244, 256, 263, 264, 268, 273, 277, 297, 314, 316, 323, 329, 331, 333, 337, 338, 340, 342, 352, 356, 368, 370, 377, 379, 380, 385, 387, 390, 391, 394, 397, 398, 400, 402, 403, 404, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 418, 419, 421, 423, 424, 426, 429, 430, 431, 432, 433, 434, 435, 436, 437, 438, 439, 440, 442, 443, 444, 445, 447, 448, 449, 450, 451, 453, 454, 455, 456, 457, 458, 459, 460, 461, 463, 464, 465, 466, 467, 468, 470, 472, 473, 474, 475, 477, 478, 479, 481, 482, 483, 484, 485, 486, 487, 488, 490, 491, 492, 493, 495, 496, 497, 498, 499, 500, 501, 502, 503, 505, 506, 507, 508, 509, 510, 511, 512, 514, 515, 516, 517, 518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530, 531, 532, 533, 535, 536, 537, 538, 539, 540, 541, 542, 544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556, 557, 558, 559, 560, 561, 562, 563, 564, 565, 566, 567, 568, 569, 570, 571, 572, 573, 574, 575, 576, 577,
@apolzon
apolzon / gist:3213509
Created July 31, 2012 04:08
HotFix Console Session

➜ homelight git:(production) git merge --no-ff hotfix-fix-dre-format-imports

Merge made by the 'recursive' strategy.

 app/controllers/admin/imports_controller.rb | 1 +

 app/models/mapped_format.rb                 | 2 +-

2 files changed, 2 insertions(+), 1 deletion(-)

@apolzon
apolzon / gist:3374293
Created August 16, 2012 22:45
Agent Availability Factor
SELECT
agents.*, agents.id as core_agent_id,
(2*buyer_factors.buyer_estimated_current_sales + seller_factors.seller_estimated_current_sales) as availability_factor,
buyer_factors.buyer_estimated_current_sales,
seller_factors.seller_estimated_current_sales
FROM
(SELECT agent_id,
case
when last_year_q3_total_sales / cast ( nullif(sold_transactions_2011, 0) as float) <= 0.2
then buyer_estimates.sales_change_weighted_average*sold_transactions_2011/4.0
@apolzon
apolzon / TestConsole.hidden-tmTheme
Created July 12, 2013 23:24
Custom colors for the RubyTest test run pane.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>name</key>
<string>TestConsoleTheme</string>
<key>settings</key>
<array>
<dict>
<key>settings</key>