Skip to content

Instantly share code, notes, and snippets.

@garethrees
garethrees / files-exist
Last active November 6, 2019 10:11
Xapain IOError DatabaseOpeningError Error opening table
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: -
@garethrees
garethrees / gist:2379c734fd5b9f710f3e09893635a6e6
Created September 4, 2019 10:38
Clean up old VirtualBox VMs
$ 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
@garethrees
garethrees / upcoming-release-os-ruby-support.md
Last active June 6, 2019 15:20
Upcoming alaveteli release OS / Ruby support

OPERATING SYSTEM SUPPORT

0.33

  • Add Xenial
  • Drop Debian Jessie
  • Last release to support Trusty

0.34

@garethrees
garethrees / check_maxium_ids.rb
Created November 8, 2018 17:16
Check maximum ID size of ActiveRecord tables
# Oops https://m.signalvnoise.com/update-on-basecamp-3-being-stuck-in-read-only-as-of-nov-8-9-22am-cst-c41df1a58352
ids = ActiveRecord::Base.descendants.map do |klass|
begin
klass.maximum(:id)
rescue
nil
end
end
ids.compact.sort
@garethrees
garethrees / comment.md
Last active September 12, 2018 12:28
FOI Exemptions Intro

I think in general all the content here is good, but its pretty wordy and doesn't give any "landmarks" for a confused citizen to orientate themselves.

I think the main messages we want to convey here are:

  • The default position is that they must confirm or deny; then release if they have it.
  • If they've refused a request, have they applied exemptions correctly?
  • General things you can do when refused with an exemption

What do I mean by landmarks? I made a stab at showing this: https://gist.github.com/garethrees/d9acb79dbe46eb4143ffe75ca004cdc7#file-foi-exemption-intro-md

@garethrees
garethrees / merge_csv_columns.rb
Last active May 11, 2018 16:31
Merge CSV columns with same header
require 'csv'
csv = CSV.parse(<<-CSV, headers: true, header_converters: :symbol)
id,title,label,label
1,fixme,bug,backend
CSV
row = csv.first
row[:labels] = row.map { |k,v| v if k == :label }.compact
@garethrees
garethrees / tee.sh
Last active November 28, 2018 10:06
tee stderr and log both output streams
# stderr as process output, and then stdout and stderr to independent log files
command 1> stdout.log 2> >(tee -a stderr.log >&2)
# stdout as process output, and then stdout and stderr to independent log files
command 2> stderr.log 1> >(tee -a stdout.log >&1)
@garethrees
garethrees / hilong.rb
Created March 31, 2018 20:57 — forked from jstorimer/hilong.rb
hilong -- A simply utility to show character counts for each line of input and highlight lines longer than 80 characters.
#!/usr/bin/env ruby
# A simply utility to show character counts for each line of input and
# highlight lines longer than 80 characters.
#
# Written as an example for http://jstorimer.com/2011/12/12/writing-ruby-scripts-that-respect-pipelines.html
#
# Examples:
#
# $ hilong Gemfile
@garethrees
garethrees / bisect-user-phase-counts
Created March 5, 2018 12:04
Phase Counts Regression
#!/bin/bash
bundle > /dev/null 2>&1
RAILS_ENV=test bundle exec rake db:drop && RAILS_ENV=test bundle exec rake db:create && RAILS_ENV=test bundle exec rake db:migrate > /dev/null 2>&1
bundle exec rspec ./spec/models/user_spec.rb > /dev/null 2>&1
@garethrees
garethrees / resize-window.sh
Created February 22, 2018 13:22
AppleScript Resize Window
# Via https://alvinalexander.com/source-code/mac-os-x/how-size-or-resize-application-windows-applescript
# { xpos, ypos, width, height }
osascript <<-EOF
tell application "iTerm2"
set bounds of front window to {0, 0, 1200, 1440}
end tell
EOF