Generate a Ruby function to convert UK Ordnance Survey OSGB36 co-ordinates to WGS84 latitude and longitude just using pure Ruby and not using a gem.
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
def osgb36_to_wgs84(easting, northing) | |
# Ellipsoid parameters | |
a_airy = 6377563.396 # Semi-major axis (Airy 1830) | |
b_airy = 6356256.909 # Semi-minor axis (Airy 1830) | |
a_wgs84 = 6378137.0 # Semi-major axis (WGS84) | |
b_wgs84 = 6356752.3142 # Semi-minor axis (WGS84) | |
# OSGB36 Helmert transformation parameters to WGS84 | |
tx = 446.448 # Translation along X-axis (meters) | |
ty = -125.157 # Translation along Y-axis (meters) |
Generate a Ruby function to convert UK Ordnance Survey OSGB36 co-ordinates to WGS84 latitude and longitude
Generate a Ruby on Rails routes file that namespaces a resource called 'Page' under the path '/admin' and restrict it to just the index, edit and update actions.
Generate a Ruby on Rails controller for a 'Page' resource that is namespaced inside a module called 'Admin'. Implement the index, edit and update actions using path parameter called 'slug' to find the correct model. For the index action sort the pages by the slug column.
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
module Mapping | |
module Utilities | |
module NationalGrid | |
# All the values and formula are from the Ordnance Survey publication: | |
# A guide to coordinate systems in Great Britain | |
# https://www.ordnancesurvey.co.uk/documents/resources/guide-coordinate-systems-great-britain.pdf | |
# Scale factor on the central meridian for the Transverse Mercator projection | |
# https://en.wikipedia.org/wiki/Transverse_Mercator_projection | |
F0 = 0.9996012717 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
class ActivationsController < ApplicationController | |
respond_to :json | |
def create | |
new_password = params[:user] && params[:user][:password] | |
token = params[:confirmation_token] | |
if !new_password | |
render_errors({"password"=>["can't be blank"]}.to_json) |
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
formats = [ | |
"[A-Z]{2}[0-9]{2}[A-Z]{3}", | |
"[A-Z]{1}[0-9]{3}[A-Z]{3}", | |
"[A-Z]{3}[0-9]{3}[A-Z]{1}" | |
] | |
pattern = /\A#{formats.join("|")}\z/ | |
candidates = %w[ | |
RF10AK0 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder