Skip to content

Instantly share code, notes, and snippets.

@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 / plot.p
Last active January 14, 2024 23:21
Graphing apache benchmark results with gnuplot
# Output to a jpeg file
set terminal jpeg size 1280,720
# Set the aspect ratio of the graph
set size 1, 1
# The file to write to
set output "timeseries.jpg"
# The graph title
@garethrees
garethrees / rsync.sh
Last active December 5, 2023 13:41
rsync & scp through jump host
# Upload
rsync -av -e "ssh -A JUMP_HOST ssh" FILE_TO_SEND DEST_HOST:/home/gareth/
# Download
rsync -av -e "ssh -A JUMP_HOST ssh" DEST_HOST:~/FILE_TO_DOWNLOAD ~/Downloads/
@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 / pro_sample_data.rb
Last active September 28, 2022 08:53
Alaveteli Pro Sample Data – WARNING: Takes a few hours to run
require 'rspec/rails'
require 'factory_bot'
require Rails.root.join('spec', 'support', 'load_file_fixtures')
require Rails.root.join('spec', 'support', 'email_helpers')
RSpec.configure do |config|
config.fixture_path = "#{::Rails.root}/spec/fixtures"
end
factory_users = User.pluck(:id) - [1,2,3,4,5,6,7]
# Generate Private Key
$ openssl genrsa -out server.key 2048
# Generate CSR
$ openssl req -new -out server.csr -key server.key -config openssl.cnf
# => Fill in info
# Check CSR
$ openssl req -text -noout -in server.csr
# Sign Cert
$ openssl x509 -req -days 3650 -in server.csr -signkey server.key -out server.crt -extensions v3_req -extfile openssl.cnf
@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 / alaveteli-install.sh
Last active November 9, 2021 16:13
Alaveteli dev install
# Host
# ------------------------------------------------------------------------------
# Go to your main code directory
cd ~/Code
# Clone alaveteli
git clone --recursive https://github.com/mysociety/alaveteli.git
cd alaveteli
git checkout master # Or the specific version a site is running on, e.g. `0.20.0.14`
@garethrees
garethrees / php-fpm.ini
Last active November 4, 2021 21:56
Default php fpm pool configuration
; Start a new pool named 'www'.
[www]
; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; 'ip.add.re.ss:port' - to listen on a TCP socket to a specific address on
; a specific port;
; 'port' - to listen on a TCP socket to all addresses on a
; specific port;
; '/path/to/unix/socket' - to listen on a unix socket.
@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>