Skip to content

Instantly share code, notes, and snippets.

@chrislo
chrislo / govuk-development-vm.md
Created Feb 28, 2018 — forked from floehopper/govuk-development-vm.md
Setup GOV.UK development VM with local SSO, Whitehall & its draft stack
View govuk-development-vm.md

Data replication

The idea here is to load the routes for the router and draft-router. Life's too short to work out how to create the routes manually!

  • cd /var/govuk/govuk-puppet/development-vm/replication
  • Apply replicate-data-local.diff patch to skip all dbs on mongo-1.backend & api-mongo-1.api
  • Run the following command to import data for router & draft-router: ./replicate-data-local.sh -s -d backups/YYYY-MM-DD -p -q -e -t -i 'collections_publisher contacts release search_admin tariff_admin tariff_temporal'

Authenticating proxy

@chrislo
chrislo / fuzzy_match_courses.rb
Last active Aug 29, 2015
FuzzyMatch Courses
View fuzzy_match_courses.rb
require 'fuzzy_match'
require 'date'
require 'ostruct'
haystack = [
OpenStruct.new(
title: "Good brain, bad brain: Parkinson's disease",
start: Date.parse('24 February 2014'),
slug: 'good-brain-bad-brain-parks'),
OpenStruct.new(
@chrislo
chrislo / fuzzy_match_strings.rb
Last active Aug 29, 2015
FuzzyMatch a list of strings
View fuzzy_match_strings.rb
require 'fuzzy_match'
haystack = [
"Good brain, bad brain: Parkinson's disease",
"Archaeology of Portus: exploring the lost harbour of ancient Rome",
"The secret power of brands",
"The secret power of brands"
]
matcher = FuzzyMatch.new(haystack)
@chrislo
chrislo / get_survey_list.rb
Last active Aug 29, 2015
Fetch a list of surveys from SurveyMonkey
View get_survey_list.rb
response = RestClient.post(
"https://api.surveymonkey.net/v2/surveys/get_survey_list?api_key=#{KEY}",
{ fields: ["title", "date_created"] }.to_json,
'Content-Type' => 'application/json', 'Authorization' => "bearer #{TOKEN}")
View git config bash
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)\n$ '
# list remote branches with committer name and email
View keybase.md

Keybase proof

I hereby claim:

  • I am chrislo on github.
  • I am chrislowis (https://keybase.io/chrislowis) on keybase.
  • I have a public key whose fingerprint is 4E0B 406F 3E2F 5ACC E0CA F0C2 B9B8 2371 498D 0E0A

To claim this, I am signing this object:

View gist:8543385
require 'minitest/unit'
require 'minitest/autorun'
class Atom
attr_reader :symbol
def initialize(symbol)
@symbol = symbol
end
View libby_bot
class LibbyBot < RTanque::Bot::Brain
NAME = 'libby_bot'
include RTanque::Bot::BrainHelper
TURRET_FIRE_RANGE = RTanque::Heading::ONE_DEGREE * 1.0
def tick!
self.move_randomly
if (target = self.nearest_target)
View gist:5717561
$(function () {
var keyboard = qwertyHancock({id: 'keyboard'});
var context = new AudioContext();
/* VCO */
var vco = context.createOscillator();
vco.type = vco.SINE;
vco.frequency.value = this.frequency;
vco.start(0);