Skip to content

Instantly share code, notes, and snippets.

@garethrees
garethrees / inbox-labels.js
Last active November 6, 2023 13:07
Print all Gmail labels
// Go to the Inbox
// Unfold label menus (only labels visible to you will be collected)
// Open a console
var elementsWithDataLabel = document.querySelectorAll('[data-label-name]');
var dataLabelValues = Array.from(elementsWithDataLabel).map(el => el.getAttribute('data-label-name'));
dataLabelValues.forEach(value => {
console.log(value);
@garethrees
garethrees / alaveteli_pull_requests.rb
Created November 12, 2021 14:50
alaveteli_pull_requests.rb
#!/usr/bin/env ruby
require 'octokit'
require 'pp'
require 'csv'
GITHUB_TOKEN = ENV['GITHUB_TOKEN'].freeze
SINCE=ARGV[0].freeze
client = Octokit::Client.new(access_token: GITHUB_TOKEN)
@garethrees
garethrees / details.html
Last active May 18, 2021 15:08
Why different arrow behaviour?? Why?!
<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 December 10, 2020 15:24
Vim macro for erb gettext strings

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)
@garethrees
garethrees / update_defunct.rb
Created November 26, 2020 16:03
Schools Update 2020
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 July 22, 2020 10:21
Get date of each week start
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 June 1, 2020 09:28
Delete Individual Chrome Autocomplete URLs On The Address Bar
Shift + FN + Delete
Via https://trendblog.net/delete-chrome-autocomplete/
@garethrees
garethrees / format.sh
Created April 28, 2020 15:32
Format USB drive from the command line macOS
diskutil list
diskutil unmountDisk /dev/disk2
diskutil eraseDisk FAT32 SANDISK /dev/disk2
@garethrees
garethrees / Vagrantfile
Last active January 3, 2020 09:55
geocoder resolving dependencies
# -*- 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 December 11, 2019 09:35
Alaveteli Public vs Embargoed Requests per Month / Quarter
# 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).