Skip to content

Instantly share code, notes, and snippets.

@pixeltrix
pixeltrix / welsh-regions.topojson
Created May 11, 2020 16:06
Welsh Electoral Regions (TopoJSON Format)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pixeltrix
pixeltrix / welsh-constituencies.geojson
Created May 11, 2020 16:03
Welsh Electoral Constituencies
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pixeltrix
pixeltrix / welsh-regions.geojson
Last active May 11, 2020 16:00
Welsh Electoral Regions
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@pixeltrix
pixeltrix / sonar.rb
Last active May 9, 2020 21:53
Ruby implementation of the NHS contact tracing app's messages and how they're decrypted
require "openssl"
require "securerandom"
##########################
### iOS/Android Device ###
##########################
# Installation id - returned by the registration request
uuid = "E1D160C7-F6E8-48BC-8687-63C696D910CB"
uuid_bytes = uuid.scan(/[0-9A-Z]{2}/).map { |s| s.to_i(16) }.pack("C*")
@pixeltrix
pixeltrix / markdown_helper.rb
Last active April 13, 2020 11:19
Stub out requests to GOV.UK Notify, convert them into Mail::Message instances and stash them into ActionMailer::Base.deliveries
# app/helpers/markdown_helper.rb
require "redcarpet/render_strip"
module MarkdownHelper
HTML_DEFAULTS = {
escape_html: false, filter_html: false,
hard_wrap: true, xhtml: true, safe_links_only: true,
no_styles: true, no_images: true, no_links: false,
with_toc_data: false, prettify: false, link_attributes: {}
}
@pixeltrix
pixeltrix / signals.json
Created March 24, 2020 07:01
List of signals on Ubuntu 18.04 / Ruby 2.6.5
{
"EXIT": 0,
"HUP": 1,
"INT": 2,
"QUIT": 3,
"ILL": 4,
"TRAP": 5,
"ABRT": 6,
"IOT": 6,
"FPE": 8,
@pixeltrix
pixeltrix / migration_status.rb
Created August 30, 2019 12:39
Glue code required to get an Active Record rake task working outside of Rails
require 'rake'
require 'active_record'
require 'erb'
require 'yaml'
ActiveRecord::Tasks::DatabaseTasks.migrations_paths = [File.expand_path('db/migrate')]
module Rails
def self.env
'development'
@pixeltrix
pixeltrix / toy_robot.rb
Created May 15, 2019 12:47
Ruby implementation of the common code exercise
require "matrix"
require "readline"
class ToyRobot
PROMPT = "> "
PLACE = /\APLACE\s+(\d+),(\d+),(NORTH|SOUTH|EAST|WEST)\z/
COMMAND = /\ALEFT|RIGHT|MOVE|REPORT\z/
QUIT = /\AQUIT\z/
LEFT = Matrix[[0, 1], [-1, 0]]
RIGHT = Matrix[[0, -1], [ 1, 0]]
<!DOCTYPE html>
<html>
<head>
<title>FSM</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.css" type="text/css">
<style>
body {
font-family: "Helvetica Neue", Helvetica, Arial, Sans-Serif;
margin: 0;