Skip to content

Instantly share code, notes, and snippets.

View timrogers's full-sized avatar

Tim Rogers timrogers

View GitHub Profile
@timrogers
timrogers / gist:ef7a0070d29ea1ffa5d925184e7a4887
Created July 23, 2020 10:29
Example fare rules for an American Airlines flight from New York to San Francisco, with fare basis code NVAKZNM3
Rule Application
PTC - ADT
TARIFF/RULE - 011/M11K
ROUTING NUMBER - 304/TYPEPrice/DEP**JFK/ARR**SFO/:CT1(JFK):CT2(SFO):ITA
ONE WAY INSTANT PURCHASE FARES N
APPLIES FOR ONE WAY FARES
FOR ADULT
Flight Application
@timrogers
timrogers / herokuize.sh
Created July 31, 2016 14:23
herokuize, a script for seeding your local Rails environment from Heroku. Just specify $PG_USERNAME and $PG_DATABASE.
#!/bin/bash
heroku pg:backups capture
curl -o latest.dump `heroku pg:backups public-url`
bundle exec rake db:drop db:create
pg_restore --verbose --clean --no-acl --no-owner -h localhost -U $PG_USERNAME -d $PG_DATABASE latest.dump
rm latest.dump
@timrogers
timrogers / gist:57a67478ea575d6a7e7c
Created January 17, 2016 21:11
Sample tweet data from Twitter Streaming API
{
"created_at":"Sun Jan 17 17:52:50 +0000 2016",
"id":688781035077787650,
"id_str":"688781035077787650",
"text":"Testing with #VoteRemain",
"source":"\u003ca href=\"http://itunes.apple.com/us/app/twitter/id409789998?mt=12\" rel=\"nofollow\"\u003eTwitter for Mac\u003c/a\u003e",
"truncated":false,
"in_reply_to_status_id":null,
"in_reply_to_status_id_str":null,
"in_reply_to_user_id":null,
SELECT * FROM `salesforce1` WHERE `description` != 'Reversal' AND `id` IN ('85092508', '85092362', '85063063', '84817289', '85063064', '85063383', '85063384', '85037123', '85037124', '85062121', '85064887', '85064888', '85063292', '85063433', '85062482', '85062483', '85062942', '85062943', '85095302', '85049491', '85049492', '85063161', '85065160', '85065161', '85063561', '85063566', '85063582', '85063622', '85063649', '85065055', '85065224', '85063568', '85065284', '85065285', '85065349', '85065386', '85096528', '84929541', 'Tried to', '85065445', '85065483', '85065501', '85065587', '85065903', '85065940', '85065948', '85065941', '85065791', '85065792', '85065949', '85065225', '85066035', '85066068', '85066084', '85066125', '85065438', '85066133', '84934801', '84969645', '85097914', '85097915', '85098803', '85096560', '85096561', '85037628', '85066156', '85066548', '85066549', '85067236', '85067674', '85065351', '85067798', '85067799', '85068088', '85068089', '85066729', '85066730', '85101244', '85038023', '
@timrogers
timrogers / lse_renew_o_matic.rb
Last active December 25, 2015 21:59
Automatically renew library books from the London School of Economics (LSE) library from a Ruby script with the LSE Renew-o-matic
# LSE Renew-o-matic
# Renew books you've taken out from the library at LSE (the British Library of Political
# and Economic Science) just by running a Ruby script
#
# Step 1: Install the gem dependencies
# $ gem install terminal-table mechanize
# Step 2: Run, and you'll get a beautiful table at the end with the results!
require 'terminal-table'
require 'mechanize'
Hello,
We're writing about #111-8797241-1992259 for Google Chromecast HDMI Streaming Media Player. We recently learned of an error that allowed this item to be available to ship to international addresses. Unfortunately, this item is not currently intended for use outside of the United States. Outside of the United States, all of the functionality of this item may not be available and the manufacturer's warranty is void. We're sorry for any inconvenience this causes.
You don't need to take any action if you still want to receive the item. If your order hasn’t shipped yet, you can cancel it by going to Your Account and clicking the "Your Orders" button:
http://www.amazon.com/your-account
If your order has shipped and you would like to return the item, you'll find return instructions at the link below. We'll refund you in full, including the return shipping costs.
<?php
// ...
public function cancel() {
$endpoint = self::$endpoint . '/' . $this->id . '/cancel';
return new self($this->client, $this->client->request('put', $endpoint));
}
public function refund() {
$endpoint = self::$endpoint . '/' . $this->id . '/refund';
return new self($this->client, $this->client->request('post', $endpoint));
@timrogers
timrogers / gist:6528957
Created September 11, 2013 19:58
in_business configuration
# Configure the gem with hours of your choice, on a day-by-day basis
InBusiness.hours = {
monday: "09:00".."18:00",
tuesday: "10:00".."19:00",
# ...
saturday: "09:00".."12:00"
}
InBusiness.open? # => true (if now is within the set hours)
InBusiness.open? DateTime.parse("9th September 2013 08:00") # => false
{ "action": "created", "bills": [ { "amount": "20.0", "amount_minus_fees": "19.8", "id": "ABCD1234", "source_id": "DCBA4321", "source_type": "subscription", "status": "pending", "uri": "https://gocardless.com/api/v1/bills/ABCD1234" } ], "resource_type": "bill" }
<?php
GoCardless::$environment = 'sandbox'; // Whilst you're testing...
$account_details = array(
'app_id' => 'app id',
'app_secret' => 'app secret',
'merchant_id' => 'merchant id',
'access_token' => 'access token'
);