Skip to content

Instantly share code, notes, and snippets.

@davetroy
davetroy / twitter_output.rb
Created September 2, 2016 15:31
Simple Twitter Updater
require 'yaml'
require 'twitter'
class TwitterOutput
def initialize
@client = client
end
def client
creds = YAML.load_file('creds.yml').values.first
require 'rubygems'
require 'mechanize'
require 'google_drive'
agent = Mechanize.new
@base_url = "https://www.baltimorecitibuy.org"
page = agent.get("#{@base_url}/bso/external/publicContracts.sdo")
page.css('td[class="inputs-01"][align="center"]').first.text[/ of (\d+)/]
item_count = $1.to_i
puts "item 1 of #{item_count}"
import XCTest
@testable import NewApp
class FRCTests: CoreDataTestCase, NSFetchedResultsControllerDelegate {
var expectedProperties: [String:AnyObject]? = nil
var changeExpectation: XCTestExpectation?
var deleteExpectation: XCTestExpectation?
var insertExpectation: XCTestExpectation?
import XCTest
import TLIndexPathTools
@testable import NewApp
class TLToolsTests: CoreDataTestCase, TLIndexPathControllerDelegate {
var expectedProperties: [String:AnyObject]? = nil
var changeExpectation: XCTestExpectation?
@davetroy
davetroy / search_youtube_to_mp3.rb
Last active December 17, 2015 00:39
This simple ruby script will allow searching for and downloading video files from Youtube (as mp4 files) and then converting them to mp3 audio files, suitable for uploading to Soundcloud or a web server.
require 'rubygems'
require 'youtube_search' # https://github.com/grosser/youtube_search
require 'youtube_dl' # https://github.com/tonic20/youtube_dl
FFMPEG = "/usr/local/bin/ffmpeg"
res = YoutubeSearch.search('music|song|musicians|performance|instruments', :author => 'TEDxTalks', :per_page => 50, 'orderby' => 'viewCount')
res.each do |r|
puts "https://www.youtube.com/watch?v=#{r['video_id']} <#{r['title']}>"
youtube = YoutubeDl::YoutubeVideo.new("http://www.youtube.com/watch?v=#{r['video_id']}", :location => './video')
@davetroy
davetroy / gist:4572545
Created January 19, 2013 12:56
Edits to Max Skibinsky's excellent essay on Gödel incompleteness for startups. http://skibinsky.com/godel-incompleteness-for-startups/
s/Wheather/Weather
s/anything more powerful then Gödel/anything more powerful than Gödel's/
s/deductions wont/deductions won't/
s/that maps refers/that map refers/
s/Lets work/Let's work/
s/complicated then arithmetic/complicated than arithmetic
s/in such system/in such a system/
s/cannot at same time/cannot at the same time/
s/higher then average/higher than average/
s/or disproved it/or disprove it/
@davetroy
davetroy / trails2.rb
Created September 6, 2012 16:36
Parse tweets into csv trails
require 'rubygems'
require 'time'
require 'yajl'
require 'yajl/json_gem'
require 'csv'
PARSER = Yajl::Parser.new
def add_point(s)
if s['geo']
@davetroy
davetroy / stream.rb
Created August 29, 2012 19:32
Capture tweets for a given lat/lon bounding box
#!/usr/bin/env ruby
$: << File.dirname(__FILE__)
require 'rubygems'
require 'eventmachine'
require 'em-http'
require 'yajl'
require 'yajl/json_gem'
class Streamer
{
"lon": -76.74754313,
"coordinates": {
"coordinates": [-76.74754313, 39.2086797],
"type": "Point"
},
"truncated": false,
"favorited": false,
"created_at": "Wed Aug 29 04:01:40 +0000 2012",
"timestamp": 1346212900,
@davetroy
davetroy / tweetparse.rb
Created August 28, 2012 19:29
Parse tweets from baltimore.twittervision.com
require 'rubygems'
require 'yajl'
require 'fastercsv'
tweetfile = ARGV[0]
PARSER = Yajl::Parser.new
def output_tweet(s)
if s['geo']