Item | Image path | Last Attempt |
---|---|---|
Awl Case - 50.67.36 | http://cdn2.brooklynmuseum.org/images/opencollection/objects/size3/50.67.59a-b_50.67.41_50.67.36_possibly_50.67.121_50.67.137_and+unknown_glass_bw.jpg |
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
gem 'rails', :git => 'git://github.com/rails/rails.git', :ref => 'c1f397f82c7b3f352500832a399b5dbdc500b9c8'# change as required | |
require 'active_record' | |
require 'logger' | |
# Show ActiveRecord log output | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
# Print out what version we're running | |
puts "Active Record #{ActiveRecord::VERSION::STRING}" |
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
gem 'rails', :git => 'git://github.com/rails/rails.git', :ref => 'c1f397f82c7b3f352500832a399b5dbdc500b9c8'# change as required | |
require 'active_record' | |
require 'logger' | |
# Show ActiveRecord log output | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
# Print out what version we're running | |
puts "Active Record #{ActiveRecord::VERSION::STRING}" |
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
[50, 100, 200, 500, 1000, 5000].each do |buffer| | |
puts "Calculating population within #{buffer} m of each shape_geometry" | |
Shape.find_each do |s| | |
execute "UPDATE shapes SET pop#{buffer}m = | |
(SELECT SUM((ST_SummaryStats(ST_Clip(rast,1,ST_Buffer(geom::geography, #{buffer})::geometry))).sum) | |
FROM shapes, population_tiles | |
WHERE id = #{s.id} AND ST_Intersects(ST_Buffer(geom::geography, #{buffer})::geometry,rast) | |
GROUP BY id) | |
WHERE id = #{s.id}" | |
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
DISPERSION_FACTORS = {50 => 0.5341, 100 => 0.3610, 200 => 0.5145, 500 => 0.9159, 1000 => 0.9088, 5000 => 4.662} | |
# Calculate the intake fraction where iF = SUM(popN * DispN) / 1000 | |
# where popN is the population in an N meter buffer minus the previous population buffer | |
def intake_fraction | |
fraction = 0 | |
inner_pop = 0 | |
DISPERSION_FACTORS.each do |buffer, value| | |
pop_in_buffer = send("pop#{buffer}m").to_i | |
fraction += (pop_in_buffer - inner_pop) * value * 0.62 * 14.5 |
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
# Calculate the intake fraction where iF = SUM(popDensN * DispN) | |
# where popDensN is the population density in an N meter buffer minus the previous buffer | |
def intake_fraction | |
fraction = 0 | |
inner_pop = 0 | |
inner_area = 0 | |
DISPERSION_FACTORS.each do |buffer, value| | |
pop_in_buffer = send("pop#{buffer}m").to_i | |
area_in_buffer = send("area#{buffer}m").to_i |
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
class CreateModels < ActiveRecord::Migration | |
def change | |
create_table :items do |t| | |
end | |
end | |
end | |
class Item < ActiveRecord::Base | |
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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', github: 'rails/rails' | |
gem 'arel', github: 'rails/arel' | |
gem 'rack', github: 'rack/rack' | |
gem 'i18n', github: 'svenfuchs/i18n' | |
gem 'sqlite3' | |
GEMFILE |
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
en: | |
new: "New" | |
edit: "Edit" | |
delete: "Delete" | |
cancel: "Cancel" | |
import: "Import" | |
error: "Error" | |
toggle_navigation: "Toggle Navigation" |
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
#!/usr/bin/env ruby | |
require 'csv' | |
Dir.chdir File.dirname(__FILE__) | |
class String | |
def green; "\e[32m#{self}\e[0m" end | |
def yellow; "\e[33m#{self}\e[0m" end | |
end |
OlderNewer