Skip to content

Instantly share code, notes, and snippets.

@pixeltrix
pixeltrix / osgb36_to_wgs84.rb
Created January 27, 2025 13:32
OpenAI 4o response to being asked to generate a function to convert easting/northing to lat/lng
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)
@pixeltrix
pixeltrix / 01.prompt.md
Created January 27, 2025 07:55
Deepseek responses when asked to generate a function to convert OSGB36 to WGS84 co-ordinates using pure Ruby

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.

@pixeltrix
pixeltrix / 01.prompt.md
Last active January 27, 2025 07:54
Deepseek responses when asked to generate a function to convert OSGB36 to WGS84 co-ordinates

Generate a Ruby function to convert UK Ordnance Survey OSGB36 co-ordinates to WGS84 latitude and longitude

@pixeltrix
pixeltrix / 01.prompt.md
Created January 27, 2025 07:52
Deepseek responses when asked to build routes file

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.

@pixeltrix
pixeltrix / 01.prompt.md
Last active January 27, 2025 07:50
Deepseek responses when asked to build a Ruby on Rails controller

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.

@pixeltrix
pixeltrix / mapping.rb
Created April 11, 2024 06:54
Utility functions for converting between OSGB36 and WGS84 co-ordinates
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
@pixeltrix
pixeltrix / truffleruby-logo.svg
Last active July 27, 2021 07:30
Truffle logo in SVG with outline shadow layer
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pixeltrix
pixeltrix / activations_controller.rb
Last active May 26, 2020 10:15
Example of a 'service' object
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)
@pixeltrix
pixeltrix / anpr.rb
Created May 13, 2020 10:21
Match one of three number plate patterns
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
@pixeltrix
pixeltrix / welsh-constituencies.topojson
Created May 11, 2020 16:09
Welsh Electoral Constituencies (TopoJSON Format)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.