This file contains hidden or 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
TableFilterer.prototype.addClickHandler = function(el,facet,featuredness) { | |
tFinstance = this; | |
$(el).live('click',function() { | |
var entity = $(this).attr("data-"+facet); | |
var type = $(this).children('h4').html(); | |
//for race "permalinks" | |
if (!_.isNaN(parseInt(entity))) { | |
entity = parseInt(entity); |
This file contains hidden or 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
task :featured do | |
featured_sen_races = Race.where(:office_id => "S", :state_postal => %w[NV KY CO CA WI IL LA PA FL WA]) | |
featured_sen_races.collect {|q| q.featured = true} | |
featured_sen_races.each(&:save) | |
end |
This file contains hidden or 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 'rubygems' | |
require 'yajl/json_gem' | |
module AP | |
# a = AP::ParseData.new('/file.txt') | |
class ParseData | |
def initialize(file) | |
@file = file | |
@ap_scratch = [] | |
@final_results = [] |
This file contains hidden or 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 'rubygems' | |
require 'yajl/json_gem' | |
module AP | |
# a = AP::ParseData.new('/file.txt') | |
class ParseData | |
def initialize(file) | |
@file = file | |
@ap_scratch = [] | |
@final_results = [] |
This file contains hidden or 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
<a href="http://twitter.com/?status=RT%20@<%= update.author_username %>%20<%= CGI::escape(update.body).gsub(/\+/,'%20') %>">RT</a> |
This file contains hidden or 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
[ | |
{ | |
"update": { | |
"location": "http://www.talkingpointsmemo.com/live/tpm-midterms-wire/index.xml", | |
"created_at": "2010-10-07T16:58:03Z", | |
"author_username": "Brian Beutler", | |
"title": "Brutal Dem Ad Cites GOP Candidate Role In Illegal Strip Searches Of Teenage Girls (VIDEO)", | |
"native_item_id": "tag:www.talkingpointsmemo.com,2010:/live//14117.354325", | |
"body": "<p>The Democrats don't really have a cavalry of outside groups this year to run the sorts of hard-hitting ads that the parties typically like to keep some distance from. So this year, they have little choice but to run them on their own.</p>\n\n<p>This DCCC ad might be the most brutal of the cycle.</p>", | |
"via": "atom", |
This file contains hidden or 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/jst" id="live_update_tmpl"> | |
<% _(window.mw_check_for_updates.new_updates).each(function(update) { %> | |
<% var twitter; %> | |
<% if (update.via === "twitter") { twitter = true; } %> | |
<div class="topic_story_wrap <% if (twitter) { %>twitter_story_wrap<% } %>"> | |
<% if (!twitter) { %> | |
<h2 class="eyebrow updating_wire_eyebrow"><%= update.item_create_time %> | <%= update.author_display_name %></h2> | |
<% } %> | |
This file contains hidden or 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
irb(main):094:0> param_re = /[?&]([\w]+)=?([\w]+)?/ | |
=> /[?&]([\w]+)=?([\w]+)?/ | |
irb(main):095:0> "http://google.com?foo=bar&baz=bag&woz=wag".scan(param_re) | |
=> [["foo", "bar"], ["baz", "bag"], ["woz", "wag"]] | |
irb(main):096:0> "http://f.g?b".scan(param_re) | |
=> [["b", nil]] | |
irb(main):097:0> "http://z.com?f&g=foo".scan(param_re) | |
=> [["f", nil], ["g", "foo"]] | |
irb(main):098:0> "http://z.com?352=deg&w22=33".scan(param_re) | |
=> [["352", "deg"], ["w22", "33"]] |
This file contains hidden or 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 to_db | |
# @payload.each do |item| | |
# u = Update.find_by_native_item_id(item[:native_item_id]) | |
# u.nil? ? r = Update.new : r = u | |
# item.each {|k,v| r[k.to_sym] = v } | |
# r.save | |
# end | |
# end | |
it "should edit existing posts in the db, if original atom entries change" do |
This file contains hidden or 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
$ spec multi_wire_spec.rb | |
MultiWire | |
== CreateMultiwireDb: migrating ============================================== | |
-- create_table(:updates) | |
-> 0.0133s | |
== CreateMultiwireDb: migrated (0.0149s) ===================================== | |
- should migrate the db correctly | |
- should load wire XML from fixture |