Skip to content

Instantly share code, notes, and snippets.

View jnicho02's full-sized avatar

Jez Nicholson jnicho02

View GitHub Profile
Take a look at the Rails Guide to Testing: http://guides.rubyonrails.org/testing.html
Rails has unit testing using MiniTest by default.
When you ran the scaffolding it created a controller test /test/controllers/topics_controller_test.rb
Add to /test/models/topic_test.rb:
class TopicTest < ActiveSupport::TestCase
test "set a title" do
t = Topic.new
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@jnicho02
jnicho02 / nevada_state_historical_markers.rb
Created March 18, 2018 12:51
parse Nevada State historical markers
require 'json'
require 'nokogiri'
require 'open-uri'
r = /([\w\W]*)([NEVADA ]*[STATE ]*[CENTENNIAL ]*[HISTORIC[AL]*]* MA[R]*KER)\s(No.|No|number)\W*(\d*)\W*(.*)\W*(.*)\W*(.*)\W*(.*)\W*(.*)\W*/i
j = JSON.parse(open('http://shpo.nv.gov/historical-markers-json').read)
j.each do |js|
puts "#{js['slug']}"
output = Nokogiri::HTML(open("http://shpo.nv.gov/nevadas-historical-markers/historical-markers/#{js['slug']}"))
contents = output.search('.//article/p').text.strip
@jnicho02
jnicho02 / merge-geojsons.py
Created June 6, 2019 14:54 — forked from migurski/merge-geojsons.py
Merge multiple GeoJSON files into one
from json import load, JSONEncoder
from optparse import OptionParser
from re import compile
float_pat = compile(r'^-?\d+\.\d+(e-?\d+)?$')
charfloat_pat = compile(r'^[\[,\,]-?\d+\.\d+(e-?\d+)?$')
parser = OptionParser(usage="""%prog [options]
Group multiple GeoJSON files into one output file.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.