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
<!-- #include file="incfiles/v09_pagedata.asp" --> | |
<!-- #include file="incfiles/adovbs.inc" --> | |
<% DisplayHeader "Paul Bogard's Non-Icthyophagous Website", "<b>home</b>" %> | |
<!-- BEGIN BODY --> | |
<% | |
' Banner Ad Randomizer Script | |
Dim listLen, tN1, tN2, tN3, tN4, tN5 |
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
require "net/http" | |
require "uri" | |
require "nokogiri" | |
def to_ascii(input_string) | |
input_string.gsub!(/\n/, "") | |
input_string.gsub!(/[”“]/, '"') | |
input_string.gsub!(/[‘’]/, "'") | |
input_string.gsub!(/[–—]/, "-") | |
input_string.encode(Encoding.find('ASCII'), {invalid: :replace, undef: :replace, universal_newline: true}) |
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/helpers/application_helper.rb | |
def render_message(type, text) | |
render partial: "layouts/message", locals: {type: type, text: text} | |
end |
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/views/layouts/_message.html.erb --> | |
<div class="message message-<%= type %>"><%= text.html_safe %></div> |
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/controllers/application_controller.rb | |
def add_message(type, text) | |
@messages ||= [] | |
@messages.push({type: type, text: text}) | |
end |
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/helpers/application_helper.rb | |
def render_messages | |
order = [:error, :warning, :success, :info] | |
@messages ||= [] | |
@messages.concat(flash.map{|k,v| {type: k.to_sym, text: v}}) if flash | |
@messages.sort_by{|m| order.index(m[:type]) || order.length} | |
.map{|m| render_message(m[:type], m[:text]) }.join.html_safe | |
end |
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/views/layouts/application.html.erb --> | |
<%= render_messages %> |
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
$color-pax-aus: #FFAE00; | |
$color-pax-east: #D9272D; | |
$color-pax-south: #FF7600; | |
$color-pax-west: #007DBB; | |
@mixin pax($color-base) { | |
a { | |
background: $color-base; | |
background: linear-gradient($color-base, darken($color-base, 5%)); | |
border: 1px solid lighten($color-base, 10%); |
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/models/airport.rb | |
... | |
# Take a collection of strings representing the starts of ICAO codes, and | |
# return an a hash of airports in the region, with airport ids as keys and | |
# IATA codes as values. | |
# Params: | |
# +icao_starts+:: An array of strings of the start of ICAO codes (i.e. EG, K) | |
def self.in_region_hash(icao_starts) |
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 |
OlderNewer