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
<?xml version="1.0" encoding="UTF-8" ?> | |
<kml xmlns="http://www.opengis.net/kml/2.2"> | |
<Document> | |
<name>Flights</name> | |
<description>Map of flight routes, created by Paul Bogard’s Flight Historian</description> | |
<Style id="airportMarker"> | |
<Icon> | |
<href>http://maps.google.com/mapfiles/kml/shapes/placemark_circle.png</href> | |
</Icon> | |
</Style> |
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
#/app/classes/map.rb | |
def gpx | |
output = %Q(<?xml version="1.0" encoding="UTF-8" ?>).html_safe | |
output += content_tag(:gpx, xmlns: "http://www.topografix.com/GPX/1/1", version: "1.1") do | |
concat (content_tag(:metadata) do | |
concat content_tag(:name, map_name) | |
concat content_tag(:desc, map_description) | |
concat (content_tag(:author) do | |
concat content_tag(:name, "Paul Bogard’s Flight Historian") |
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
#/app/classes/map.rb | |
def gpx_routes(routes) | |
return nil unless routes.any? | |
routes = routes.map{|r| r.sort_by{|x| @airport_details[x][:iata]}}.uniq.sort_by{|y| [@airport_details[y[0]][:iata], @airport_details[y[1]][:iata]]} | |
return safe_join(routes.map{|r| gpx_route(r)}) | |
end | |
def gpx_route(airport_pair) | |
detail = airport_pair.map{|a| @airport_details[a]} |
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
#/app/classes/map.rb | |
def gpx_airports(airports) | |
airports = airports.sort_by{|a| @airport_details[a][:iata]} | |
return safe_join(airports.map{|a| gpx_airport(a, :wpt)}) | |
end | |
def gpx_airport(airport_id, wpt_type) | |
detail = @airport_details[airport_id] | |
return content_tag(wpt_type, lat: detail[:latitude], lon: detail[:longitude]) do |
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
#/app/classes/map.rb | |
def gpx | |
output = %Q(<?xml version="1.0" encoding="UTF-8" ?>).html_safe | |
output += content_tag(:gpx, xmlns: "http://www.topografix.com/GPX/1/1", version: "1.1") do | |
concat (content_tag(:metadata) do | |
concat content_tag(:name, map_name) | |
concat content_tag(:desc, map_description) | |
concat (content_tag(:author) do | |
concat content_tag(:name, "Paul Bogard’s Flight Historian") |
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
#/app/classes/map.rb | |
class Map | |
include ActionView::Helpers | |
include ActionView::Context |
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
<?xml version="1.0" encoding="UTF-8" ?> | |
<gpx xmlns="http://www.topografix.com/GPX/1/1" version="1.1"> | |
<metadata> | |
<name>Flights</name> | |
<desc>Map of flight routes, created by Paul Bogard’s Flight Historian</desc> | |
<author> | |
<name>Paul Bogard’s Flight Historian</name> | |
<link href="https://www.flighthistorian.com"> | |
<text>Paul Bogard’s Flight Historian</text> |
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
sudo ifconfig en0 ether xx:xx:xx:xx:xx:xx | |
networksetup -setairportpower en0 off | |
networksetup -setairportpower en0 on | |
echo | |
echo -e "Now using $(tput bold)$(tput setaf 6)Nintendo $(tput setaf 1)Switch$(tput sgr0) MAC address (xx:xx:xx:xx:xx:xx)" | |
read -p "Press ENTER to change back to native MAC address" | |
sudo ifconfig en0 ether yy:yy:yy:yy:yy:yy | |
networksetup -setairportpower en0 off | |
networksetup -setairportpower en0 on | |
echo |
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
state_codes = %w(AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VT VA WA WV WI WY) | |
state_codes.sort! | |
one_letter_changes = Hash.new() | |
state_codes.each do |sc| | |
one_letter_changes[sc] = state_codes.select{|s| sc != s && (sc[0] == s[0] || sc[1] == s[1])} | |
end | |
def path_distance(graph, source) | |
vertexes = graph.keys | |
return nil unless vertexes.include?(source) |
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
state_codes = %w(AL AK AZ AR CA CO CT DE FL GA HI ID IL IN IA KS KY LA ME MD MA MI MN MS MO MT NE NV NH NJ NM NY NC ND OH OK OR PA RI SC SD TN TX UT VT VA WA WV WI WY) | |
state_codes.sort! | |
one_letter_changes = Hash.new() | |
state_codes.each do |sc| | |
one_letter_changes[sc] = state_codes.select{|s| sc != s && (sc[0] == s[0] || sc[1] == s[1])} | |
puts "#{sc}: #{one_letter_changes[sc].join(", ")}" | |
end |