Skip to content

Instantly share code, notes, and snippets.

View andyt's full-sized avatar

Andy Triggs andyt

  • Pembrokeshire, Wales, UK
View GitHub Profile
@andyt
andyt / cci-check.sh
Created October 1, 2015 12:15
Get and print a list of failing builds from the Concourse CI API.
#!/usr/bin/env ruby
require 'rest-client'
require 'json'
USER = 'username'
PASSWORD = 'password'
CCI_API_URL = 'https://cci.example.com/api/v1'
PIPELINE = 'cr'
def resource(path)
@andyt
andyt / stub-stripe-api-error-response.js
Created March 10, 2015 15:28
Stub a Stripe API error response
Stripe.card.createToken = function(form, handler){ handler(200, { error: { type: 'api_error', message: '**TEST** There was a problem with the Stripe API' } }) }
@andyt
andyt / sidetiq testing
Created July 23, 2014 11:33
Testing Sidetiq with sidekiq/testing
Sidekiq::Testing.fake! do
expect(
Sidetiq::Handler.new.dispatch(CreateStatementsFromBillingDetails, Time.now - 1800)
).to be_truthy
expect(
Sidetiq::Handler.new.dispatch(CreateStatementsFromBillingDetails, Time.now - 900)
).to be_truthy
end
@andyt
andyt / parse_config_ru
Created July 3, 2014 15:09
Parse config.ru
require 'rack'
describe 'config.ru' do
it 'should parse' do
expect do
Rack::Builder.parse_file(File.expand_path('../../../config.ru', __FILE__))
end.not_to raise_error
end
end
@andyt
andyt / rules.txt
Created November 28, 2012 13:27
Redirect rules created by http://www.launchthing.com/
# Generated by app.launchthing.com on 2012-11-28 13:28:08.
# This rule helps LaunchThing monitor your site.
r301 "/launchthing/verify.site", "/launchthing/verify.site.1354109287"
# : http://app.launchthing.com/projects/study-collection/rules/509e5f1adea69fd51a000002
r301 /explodingcinema/, "/explore?s=exploding%20cinema"
# : http://app.launchthing.com/projects/study-collection/rules/509e5f1adea69fd51a000003
@andyt
andyt / rules.txt
Created November 25, 2012 20:50
Redirect rules created by http://www.launchthing.com/
# Generated by app.launchthing.com on 2012-11-25 20:50:31.
# http://app.launchthing.com/projects/study-collection/rules/509e5f1adea69fd51a000002
r301 /explodingcinema/, "/explore?s=exploding%20cinema"
# http://app.launchthing.com/projects/study-collection/rules/509e5f1adea69fd51a000003
r301 /^\/(maziere|onlinekira)\//, "/explore?s=$1"
# http://app.launchthing.com/projects/study-collection/rules/509e5f1adea69fd51a000004
r301 /^\/artistfiles\/(.*)?\.html?$/, "/explore?s=$1"
@andyt
andyt / rules.txt
Created November 24, 2012 22:35
Redirect rules created by http://www.launchthing.com/
# Generated by app.launchthing.com on 2012-11-24 22:35:47.
#
# LaunchThing project: http://app.launchthing.com/projects/study-collection/
#
# http://app.launchthing.com/projects/study-collection/rules/509e5f1adea69fd51a000002
r301 /explodingcinema/, "/explore?s=exploding%20cinema"
# http://app.launchthing.com/projects/study-collection/rules/509e5f1adea69fd51a000003
r301 /^\/(maziere|onlinekira)\//, "/explore?s=$1"
@andyt
andyt / gist:2146950
Created March 21, 2012 13:39
Ha ha ha - just found this in some code one of our devs wrote.
DateTime.parse(ActiveRecord::Base.connection.execute("SELECT NOW();").fetch_row[0]).hour < 6
@andyt
andyt / list-gems
Created June 8, 2011 16:08
List gems currently in use across all running processes
sudo lsof|grep -i gems|awk '{ print $9 }'|grep -oE "[^/]+\-[0-9\.]+\/"|sort|uniq
# Block gsub for formatting the case of a place name.
# List of stopwords probably not exclusive...
def capitalize_town(name)
name.gsub(/\b([a-z])+\b/) { |match| ['on', 'and', 'in'].include?(match) ? match : match.capitalize }
end