Skip to content

Instantly share code, notes, and snippets.

@ashaw
ashaw / gist:604663
Created September 30, 2010 14:28 — forked from esmooov/gist:604625
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);
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 = []
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 = []
<a href="http://twitter.com/?status=RT%20@<%= update.author_username %>%20<%= CGI::escape(update.body).gsub(/\+/,'%20') %>">RT</a>
[
{
"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",
<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>
<% } %>
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"]]
# 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
$ 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