Skip to content

Instantly share code, notes, and snippets.

View range.py
>>> range(5)
[0, 1, 2, 3, 4]
>>> sum(range(5))
10
>>> def is_even(x):
... return x % 2 == 0
...
>>> [x for x in range(5) if is_even(x)]
[0, 2, 4]
>>> sum([x for x in range(5) if is_even(x)])
View gist:c86f0b7f2f34ac63c7e3b1be48b5a71d
GDS::SSO.config do |config|
config.user_model = "User"
config.oauth_id = ENV['SIGNON_OAUTH_ID']
config.oauth_secret = ENV['SIGNON_OAUTH_SECRET']
config.oauth_root_url = Plek.current.find("signon")
end
View gist:6179b0b16f1167ef534c4699e59f2fbe
```
backend-lb in /etc/nginx/sites-enabled/specialist-publisher.integration.publishing.service.gov.uk
```
location /cma-cases {
proxy_set_header Host specialist-publisher-rebuild.integration.publishing.service.gov.uk;
proxy_pass https://specialist-publisher-upstream;
}
View gist:34646c10189e7a59f2f0
[backup0.backup.provider1.production.govuk.service.gov.uk] sudo: /opt/puppet/tools/bootstrap
[backup0.backup.provider1.production.govuk.service.gov.uk] sudo: /opt/puppet/tools/puppet-apply --environment production
[backup0.backup.provider1.production.govuk.service.gov.uk] out: Warning: Could not retrieve fact fqdn
[backup0.backup.provider1.production.govuk.service.gov.uk] out: Warning: Host is missing hostname and/or domain: offsite-backup-1
[backup0.backup.provider1.production.govuk.service.gov.uk] out: Error: Must pass graphite_disks to Class[Base::Mounts] at /opt/puppet/manifests/nodes.pp:3 on node offsite-backup-1
[backup0.backup.provider1.production.govuk.service.gov.uk] out: Error: Must pass graphite_disks to Class[Base::Mounts] at /opt/puppet/manifests/nodes.pp:3 on node offsite-backup-1
[backup0.backup.provider1.production.govuk.service.gov.uk] out:
View defined_type_definition.diff
diff --git a/modules/govuk_postgresql/manifests/db.pp b/modules/govuk_postgresql/manifests/db.pp
index ce2179b..4624170 100644
--- a/modules/govuk_postgresql/manifests/db.pp
+++ b/modules/govuk_postgresql/manifests/db.pp
@@ -16,6 +16,10 @@
# call to postgresql_password to enable it to be passed in to the
# postgresql::server::db type.
#
+# [*collectd_password*]
+# The plaintext password for the 'collectd' PostgreSQL user to collect
View mongo-replicaset-priority.js
var expectedReplicaSetMembers = [
{
_id: 0,
host: 'api-mongo-1:27017'
},
{
_id: 1,
host: 'api-mongo-2:27017'
},
{
@alexmuller
alexmuller / git-list-old-files.sh
Created Jul 27, 2015
Git: list files not recently modified
View git-list-old-files.sh
git ls-tree -r --name-only HEAD | while read filename; do
echo "$(git log -1 --format="%ad" --date=iso -- $filename) $filename"
done | sort
View compare_vapps.rb
require 'yaml'
vdcs = ['api', 'backend', 'frontend', 'management', 'redirector', 'router']
providers = ['production_skyscape', 'staging_carrenza']
parsed = []
vdcs.each do |vdc|
providers.each do |provider|
View gist:5b2707d069bf23bd5687
$ curl --silent http://www.tomscott.com/updates.xml | grep "10 Jul 2015" -C4
<item>
<title>This RSS feed now includes videos from YouTube!</title>
<link>http://www.youtube.com/c/TomScottGo</link>
<description>Hope that helps.</description>
<pubDate>Fri, 10 Jul 2015 07:30:00 -0700</pubDate>
<guid isPermaLink="false">ts-1-83q94ujler</guid>
</item>
@alexmuller
alexmuller / header_method.rb
Last active Aug 29, 2015
A firebreak project to enable Content-Security-Policy on GOV.UK
View header_method.rb
def set_content_security_policy
asset_hosts = "http://static.dev.gov.uk http://assets-origin.dev.gov.uk"
default_src = "default-src 'none'"
script_src = "script-src #{asset_hosts} http://www.google-analytics.com 'unsafe-inline'"
style_src = "style-src #{asset_hosts} 'unsafe-inline'"
img_src = "img-src #{asset_hosts}"
report_uri = "report-uri http://www.dev.gov.uk:8080/e"
csp_header = "#{default_src}; #{script_src}; #{style_src}; #{img_src}; #{report_uri}"