Skip to content

Instantly share code, notes, and snippets.

@fofr
fofr / split_mjv5_png.sh
Created March 22, 2023 22:16
A bash script to split a Midjourney v5 grid of images using ImageMagick
#!/bin/bash
# Check if 'convert' is available
if ! command -v convert &> /dev/null; then
echo "'convert' command not found. Please install ImageMagick and try again."
exit 1
fi
input_file="$1"
@fofr
fofr / heroku_copy_config.sh
Created April 4, 2018 13:25
Copy Heroku config variables
#!/bin/bash
# Source: http://blog.nonuby.com/blog/2012/07/05/copying-env-vars-from-one-heroku-app-to-another/
set -e
sourceApp="$1"
targetApp="$2"
while read key value; do
@fofr
fofr / random.rb
Created January 19, 2018 15:52
Random example before this week
# document_type can be set, otherwise it defaults to the same value as schema_type
def setup_and_visit_random_content_item(document_type: schema_type)
schema = GovukSchemas::Schema.find(frontend_schema: schema_type)
# The schema and random example is generated from schema_type
random_example = GovukSchemas::RandomExample.new(schema: schema)
# But the correct document type gets merged in
payload = random_example.merge_and_validate(document_type: document_type)
path = payload["base_path"]
@fofr
fofr / pages-in-first-test.csv
Created November 9, 2017 17:46
Pages in first test
We can make this file beautiful and searchable if this error is corrected: No commas found in this CSV file in line 0.
/guidance/introduction-of-statutory-participation-in-trialling-of-national-curriculum-tests-from-2016
/guidance/schools-financial-efficiency-effective-procurement
/government/publications/listening-to-and-involving-children-and-young-people
/guidance/living-in-guatemala
/guidance/design-apprenticeships
/set-up-business
/guidance/notarial-and-documentary-services-guide-for-el-salvador
/guidance/full-time-enrolment-of-14-to-16-year-olds-in-further-education-and-sixth-form-colleges-in-2016-to-2017-academic-year
/guidance/recognised-uk-degrees
/guidance/living-in-cyprus
@fofr
fofr / test_helper.rb
Created September 18, 2017 11:34
test_helper.rb
ENV['RAILS_ENV'] ||= 'test'
require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
# Rails isn't picking up the RAILS_ENV var
# Without this line env is set to development
Rails.env = ENV['RAILS_ENV']
require 'capybara/rails'
require 'capybara/poltergeist'
require 'slimmer/test'
@fofr
fofr / regression_output.txt
Created September 13, 2017 17:02
Visual regression example output
2017-09-13T16:20:06.816918+00:00 app[web.1]: [2017-09-13 16:20:06] INFO WEBrick 1.3.1
2017-09-13T16:20:06.816953+00:00 app[web.1]: [2017-09-13 16:20:06] INFO ruby 2.3.1 (2016-04-26) [x86_64-linux]
2017-09-13T16:20:06.817359+00:00 app[web.1]: == Sinatra (v2.0.0) has taken the stage on 9089 for production with backup from WEBrick
2017-09-13T16:20:06.817768+00:00 app[web.1]: [2017-09-13 16:20:06] INFO WEBrick::HTTPServer#start: pid=4 port=9089
2017-09-13T16:20:20.609052+00:00 app[web.1]: ---> Running component guide spider on https://government-frontend-pr-459.herokuapp.com
2017-09-13T16:20:20.609070+00:00 app[web.1]: running: wraith spider /app/config/tmp_wraith_spider_component_guide_config.yaml
2017-09-13T16:20:29.527679+00:00 app[web.1]: Config validated. No serious issues found.
2017-09-13T16:20:29.527696+00:00 app[web.1]: Crawling https://government-frontend-pr-459.herokuapp.com/component-guide
2017-09-13T16:20:29.527697+00:00 app[web.1]: /component-guide
2017-09-13T16:20:29.527698+00:00 app[web.1]:
@fofr
fofr / markdown-publisher.md
Last active July 17, 2017 16:33
Markdown publisher

Markdown publisher:

  • A flat file markdown publisher
  • .md files with front-matter and govspeak content
  • Tasks within publisher to send to publishing API
  • Publishing API handles publishing, markdown conversion, etc, does all heavy lifting
  • Edit markdown with PR
  • Deploy re-publishes changed content
  • Lint markdown to confirm valid govspeak
  • Define a rendering app to render content, which will use components and standard mechanisms
@fofr
fofr / attachments_missing_url_to_remove.csv
Created April 11, 2017 13:33
Attachments with missing URLs that are not being used
document_url document_content_id attachment_content_id attachment_title
https://www.gov.uk/cma-cases/energy-price-control-appeal-british-gas-trading 59226dd3-b8a9-4f48-a4fa-dd3e4484900f 52787d3e-edd9-4259-8032-3c19889136f5 Scottish and Southern Energy Power Distribution
https://www.gov.uk/cma-cases/lookers-group-plc-shields-land-rover 3df363a4-67ed-4187-848a-ec7491609d69 e67333d8-f1ef-41cc-b8fd-20285477b962 Lookers.pdf
https://www.gov.uk/cma-cases/midcounties-co-operative-harry-tuffin-investments d4728299-6e7c-4a45-b43a-13fc5343fb59 304b9fb4-24b9-4d50-89f6-a972510b349b midcounties.pdf
@fofr
fofr / attachments_with_missing_urls.csv
Created April 11, 2017 13:32
Attachments with missing URLs
document_url document_content_id attachment_content_id attachment_title attachment_asset_url
https://www.gov.uk/cma-cases/private-motor-insurance-market-investigation 1539d14a-f25f-49a3-ba47-d75053a675fc 7aaa1da9-7d5d-4de8-8915-c492e5d55660 McLaren Autobody response to provisional findings and remedies notice\n (PDF, 88\n Kb) https://assets.publishing.service.gov.uk/media/5329df39e5274a226800032d/140211_mclaren_autobdy_response_to_provisional_findings_and_remedies_notice.pdf
https://www.gov.uk/cma-cases/private-motor-insurance-market-investigation 1539d14a-f25f-49a3-ba47-d75053a675fc 26b8ce1b-f2a0-460b-afea-abd1d1d36cbd Mike Dickinson response to remedies notice (PDF, 14\n Kb) https://assets.publishing.service.gov.uk/media/5329df39e5274a226b000279/140211_mike_dickinson_response_to_remedies_notice.pdf
https://www.gov.uk/cma-cases/private-motor-insurance-market-investigation 1539d14a-f25f-49a3-ba47-d75053a675fc d8ed79ce-a9db-461d-a5f7-374f8474e6ff Response to remedies notice (PDF, 99\n Kb) https://ass
@fofr
fofr / schema_features.md
Last active January 30, 2017 15:20
Features found in "details" and "links" with frequency

Running this script:

task :schema_heuristics do
  usage = {}

  Dir.glob("formats/*/publisher/details.json").each do |filename|
    data = JSON.parse(File.read(filename))
    data["properties"].keys.each do |key|
 if usage[key]