Skip to content

Instantly share code, notes, and snippets.

diff --git a/Vagrantfile b/Vagrantfile
index 82d0f6a0a..d80575e22 100644
--- a/Vagrantfile
+++ b/Vagrantfile
@@ -117,7 +117,7 @@ end
SUPPORTED_OPERATING_SYSTEMS = {
'trusty64' => 'https://atlas.hashicorp.com/ubuntu/boxes/trusty64/versions/20160714.0.0/providers/virtualbox.box',
- 'jessie64' => 'https://atlas.hashicorp.com/puppetlabs/boxes/debian-8.2-64-nocm',
+ 'jessie64' => 'https://app.vagrantup.com/puppetlabs/boxes/debian-8.2-64-nocm',
# A
it 'renders a 404 when redirecting to an embargoed request that is not yours' do
embargoed_request = FactoryGirl.create(:embargoed_request)
get signin_path, r: show_request_path(embargoed_request.url_title)
follow_redirect!
expect(response.status).to eq(404)
end
# B
it 'renders a 404 when redirecting to an embargoed request that is not yours' do
@garethrees
garethrees / packages.diff
Created October 11, 2017 08:20
config/packages vs config/packages.generic
diff --git a/config/packages b/config/packages.generic
index 55af9f249..2bdf581b8 100644
--- a/config/packages
+++ b/config/packages.generic
@@ -1,6 +1,6 @@
-# please note that this package list currently forms part of the
-# mysociety deployment infrastructure -- please discuss on the
-# alavateli mailing list if you want to change it
+
+
@garethrees
garethrees / collect_dates.rb
Last active October 9, 2017 09:31
Collect start and end of month for given time range in Ruby (Rails)
def start_and_end_of_month(date)
[date.beginning_of_month,
date.end_of_month]
end
def collect_dates(start_date, end_date = Time.zone.now.last_month.end_of_month, memo = [])
if start_date < end_date
memo << start_and_end_of_month(start_date)
collect_dates(start_date.next_month, end_date, memo)
else
@garethrees
garethrees / awk.sh
Created September 20, 2017 08:18
Sed & Awk Examples
# Print column 1
awk '{print $1}' FILE
# Print column 1 and 2, separated by '/'
awk '{print $1 "/" $2}' FILE
@garethrees
garethrees / validate_atom.sh
Created September 19, 2017 16:47
Validate an atom feed from the command line
# Save the Atom RELAX NG Compact Schema locally
# https://xml2rfc.tools.ietf.org/public/rfc/html/rfc4287.html#schema
# Just pasted in to `atom.rnc`
# Save the feed output locally
wget -O request_events.atom "https://www.whatdotheyknow.com/api/v2/body/71/request_events.atom?k=REDACTED&since_date=2017-09-15"
# Install a tool to convert comtact syntax to XML syntax
# Via https://stackoverflow.com/a/45979608/387558
brew install jing-trang
@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]
@garethrees
garethrees / factory_girl.rake
Last active September 7, 2017 11:26
Lint alaveteli factories
# -*- encoding : utf-8 -*-
require 'rspec/rails'
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.join("spec","fixtures")
end
namespace :factory_girl do
@garethrees
garethrees / to_sql.rb
Created September 7, 2017 09:05
Rails to_sql displays $1 instead of real value
# https://github.com/rails/rails/issues/15331
Comment.connection.unprepared_statement do
puts Comment.where(attention_requested: true).not_embargoed.to_sql
end
#
# bin/rails c
#
I18n.available_locales
# => [:en, :es]
Assembly.destroy_all
Part.destroy_all