Skip to content

Instantly share code, notes, and snippets.

@garethrees
garethrees / details.html
Last active May 18, 2021
Why different arrow behaviour?? Why?!
View details.html
<details open>
<summary style="display: block;">Block summary</summary>
<p>After block summary elements</p>
</details>
<br>
<br>
<details open>
<summary>Inline summary</summary>
@garethrees
garethrees / macro.md
Created Dec 10, 2020
Vim macro for erb gettext strings
View macro.md

I’m currently adding translation markup to a load of files. Here’s a before/after:

- <h3>Need to protect your scoop?</h3>
+ <h3><%= _('Need to protect your scoop?') %></h3>

Using vim-surround, this takes a few steps:

  1. ysit' (surround in tag with single quote)
View update_defunct.rb
class UpdateDefunct
GLOABL_TAG = 'school_defunct_nov2020'
def initialize(csv, dryrun: true)
@csv = csv
@dryrun = dryrun
@errors = []
@missing_bodies = []
end
@garethrees
garethrees / weeks_between.rb
Created Jul 22, 2020
Get date of each week start
View weeks_between.rb
def weeks_between(start_at, finish_at)
results = []
week_start = start_at.beginning_of_week
week_end = start_at.end_of_week
while week_end <= finish_at.end_of_week
# Collect these
results << [week_start, week_end]
@garethrees
garethrees / gist:be0344e00ddb72d2a25bcf8525c52479
Created Jun 1, 2020
Delete Individual Chrome Autocomplete URLs On The Address Bar
View gist:be0344e00ddb72d2a25bcf8525c52479
Shift + FN + Delete
Via https://trendblog.net/delete-chrome-autocomplete/
@garethrees
garethrees / format.sh
Created Apr 28, 2020
Format USB drive from the command line macOS
View format.sh
diskutil list
diskutil unmountDisk /dev/disk2
diskutil eraseDisk FAT32 SANDISK /dev/disk2
@garethrees
garethrees / Vagrantfile
Last active Jan 3, 2020
geocoder resolving dependencies
View Vagrantfile
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Based on https://github.com/rails/rails-dev-box
Vagrant.configure('2') do |config|
config.vm.box = 'ubuntu/cosmic64'
config.vm.box_url = 'http://cloud-images.ubuntu.com/releases/cosmic/release-20190628/ubuntu-18.10-server-cloudimg-amd64-vagrant.box'
config.vm.provision :shell, inline: <<~EOF
apt -y update
apt -y upgrade
@garethrees
garethrees / alaveteli_public_vs_embargoed_requests_per_month.rb
Created Dec 11, 2019
Alaveteli Public vs Embargoed Requests per Month / Quarter
View alaveteli_public_vs_embargoed_requests_per_month.rb
# MONTHLY
def month_starts(start_year, start_month, end_year, end_month)
(Date.new(start_year, start_month)..Date.new(end_year, end_month)).
select { |d| d.day == 1 }
end
def embargoed_ever(range)
InfoRequest.
joins(:info_request_events).
@garethrees
garethrees / files-exist
Last active Nov 6, 2019
Xapain IOError DatabaseOpeningError Error opening table
View files-exist
vagrant@alaveteli-bionic64: ~/alaveteli
$ stat /home/vagrant/alaveteli/lib/acts_as_xapian/xapiandbs/test.temp/spelling.baseA
File: /home/vagrant/alaveteli/lib/acts_as_xapian/xapiandbs/test.temp/spelling.baseA
Size: 13 Blocks: 8 IO Block: 1048576 regular file
Device: 31h/49d Inode: 1657 Links: 1
Access: (0644/-rw-r--r--) Uid: ( 1000/ vagrant) Gid: ( 1000/ vagrant)
Access: 2019-11-06 09:49:49.000000000 +0000
Modify: 2019-11-06 09:49:49.000000000 +0000
Change: 2019-11-06 09:49:49.000000000 +0000
Birth: -
View gist:2379c734fd5b9f710f3e09893635a6e6
$ VBoxManage list vms
"statements_downloader_default_1531341288237_2208" {477efbe6-ea60-4836-bf25-193bdf39500d}
"stretchvm_default_1534775043360_70904" {a5e64d88-9f1a-4d4a-b617-c1ce5931c556}
"alaveteli_default_1545227310221_56654" {d19ad4e4-3342-49c9-8fa1-adf2d13717ae}
"alaveteli_default_1565793578771_19647" {03583ac0-9b59-4e3a-8216-659510cb2b65}
$ grep -r --include="id" a5e64d88-9f1a-4d4a-b617-c1ce5931c556 ~/src
/Users/gareth/src/garethrees/stretchvm/.vagrant/machines/default/virtualbox/id:a5e64d88-9f1a-4d4a-b617-c1ce5931c556
$ cd /Users/gareth/src/garethrees/stretchvm && vagrant destroy -f