Skip to content

Instantly share code, notes, and snippets.

View jenningsanderson's full-sized avatar
🌎

Jennings Anderson jenningsanderson

🌎
View GitHub Profile
@jenningsanderson
jenningsanderson / Gemfile
Last active August 29, 2015 13:56
Working Gemfile for Rotten Potatoes Update Assignment. (From BerkleyX 169.1)
source 'https://rubygems.org'
gem 'rails', '3.2.13'
ruby '1.9.3'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
# for Heroku deployment - as described in Ap A of ELLS book
group :development, :test do
@jenningsanderson
jenningsanderson / extract_geo_tagged.rb
Last active August 29, 2015 13:56
Ruby script for extracting the coordinates from the Colorado Flood Tweets. Generates file ~ 1mb. Includes integer dates for Tilemill styling.
require 'json'
require 'csv'
require 'time'
file_path = '/path/to/2013ColoradoFloods.json'
#Open the CSV
CSV.open("/path/to/where/you/want/csv/geo_tagged_for_TM.csv", "w") do |csv|
csv << ["Lon", "Lat", "Date", "SortDate", "User", "Text"]
@jenningsanderson
jenningsanderson / ruby-geo-processing.rb
Created February 13, 2014 02:58
Sample geo-processing basics (Reading shapefiles) with Ruby.
## This first one can only read shapefiles
require 'rgeo-shapefile'
puts "This is a test of reading a shapefile"
shape = RGeo::Shapefile::Reader.open('../lab3/data/interestAreas.shp')
shape.each do |record|
puts record.geometry.area
end
puts shape.open?
shape.close
puts shape.open?
@jenningsanderson
jenningsanderson / MoodleScraper.rb
Created February 13, 2014 23:22
Scrape a Moodle forum or forums, generate CSV of unique participants.
#http://stackoverflow.com/questions/19271622/rails-ruby-mechanize-how-to-get-a-page-after-redirection
require 'rubygems'
require 'nokogiri'
require 'open-uri'
require 'mechanize'
require 'csv'
class MoodleScraper
attr_writer :base
require 'json'
require 'csv'
require 'time'
file_in = '/Users/jenningsanderson/Documents/Boulder_Floods/2013ColoradoFloods.json'
file_out = "/Users/jenningsanderson/Dropbox/SocialComputing/GroupMiniProject-GeoCoded/geo_tagged_counts.csv"
def get_geo_users(in_file)
screen_names = []
ticker=0
require 'json'
require 'csv'
require 'time'
file_in = '/Users/jenningsanderson/Documents/Boulder_Floods/2013ColoradoFloods.json'
file_out = "/Users/jenningsanderson/Dropbox/SocialComputing/GroupMiniProject-GeoCoded/geo_tagged_counts_ignoreRTs.csv"
def get_geo_users(in_file)
screen_names = []
ticker=0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.