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
#! /usr/bin/env ruby | |
require "json" | |
infile = "antarctica_hits" | |
lines = File.readlines infile | |
parsed_lines = lines.map do |line| | |
line = line.gsub(/2014-02-28T12-ip-10.*\.internal:/, "") | |
JSON.parse(line) rescue next |
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 'curb' | |
require 'json' | |
require 'sinatra' | |
last_poll = Time.now | |
poll_interval = 10 | |
borked_videos = [] | |
EXPECT_ENCODINGS = ['video/mp4','video/3gp:small','video/3gp:large','video/m3u8','video/webm'] | |
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
define(['angular', 'lodash'], function(angular, _) { | |
'use strict'; | |
var mod = angular.module('guardianCardServices', []); | |
// Matches on any Guardian content URL | |
// Higher priority services (e.g. video embed) should be tried first | |
var guCardUriPattern = /https?:\/\/www\.theguardian\.com\/.*\/\d{4}\/.*/; | |
// var guCardEmbedApiHost = "http://embed.theguardian.com/oembed/" |
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 "twitter" | |
require "curb" | |
require "pp" | |
require "json" | |
require "opengraph_parser" | |
puts "Authenticating..." | |
client = Twitter::REST::Client.new do |config| | |
config.consumer_key = "foo" |
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
# home.erb.html | |
<% @current_user.following.each do |user| %> | |
<%= user['status'] %><br /><br /> | |
<% end %> | |
# @current_user.following is a hash from JSON.parse(twitter_response) | |
# the above returns something like the following once per user | |
{"in_reply_to_status_id_str"=>nil, "text"=>"This Week In Dylan Lewis John Martin, a must-listen for anyone who follows @dylanljmartin http://thisweekindljm.podomatic.com", "contributors"=>nil, "retweeted"=>false, "in_reply_to_user_id_str"=>nil, "retweet_count"=>0, "id_str"=>"47517965167505408", "source"=>"web", "geo"=>nil, "truncated"=>false, "created_at"=>"Tue Mar 15 04:42:20 +0000 2011", "place"=>nil, "in_reply_to_status_id"=>nil, "favorited"=>false, "coordinates"=>nil, "id"=>47517965167505408, "in_reply_to_screen_name"=>nil, "in_reply_to_user_id"=>nil} |
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
<div class="followed-user <%= cycle('odd odd-row', 'even odd-row', 'odd even-row', 'even even-row') %><% if(followed_user_counter > 20) %> hidden<% 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
# "Empty" results when this model method resides in a cache block | |
# app/models/user.rb | |
def following(cursor = -1) | |
Rails.cache.fetch("following/#{id}", :expires_in => 1.hour) do | |
result = twitter_request_authenticated('get_following', {:cursor => cursor}) | |
followed_users = parse_body(result)['users'] | |
twitter_user_list = [] | |
followed_users.each do |user| |
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 following(cursor = -1) | |
Rails.cache.fetch("following/#{id}", :expires_in => 1.hour) do | |
result = twitter_request_authenticated('get_following', {:cursor => cursor}) | |
followed_users = parse_body(result)['users'] | |
twitter_user_list = [] | |
followed_users.each do |user| | |
# this_user = TwitterUser.new(:twitter_id => user['id'], :screen_name => user['screen_name'], :name => user['name'], :image => user['profile_image_url'], :location => user['location']) | |
this_user = {'twitter_id' => user['id'], 'screen_name' => user['screen_name'], 'name' => user['name'], 'image' => user['profile_image_url'], 'location' => user['location']} | |
this_user['status'] = user['status']['text'] unless user['status'].nil? | |
twitter_user_list.push this_user |
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
class Suggester | |
class << self | |
def variants_for word | |
[word.downcase, word.capitalize, word.squeeze] | |
end | |
def suggestions_for word | |
suggestions = self.vowel_suggestions_for word | |
suggestion_variants = [] |
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
#! /usr/bin/ruby | |
require 'dictionary' | |
require 'suggester' | |
dict = Dictionary.new | |
loop do | |
print '> ' | |
word = gets |
OlderNewer