Skip to content

Instantly share code, notes, and snippets.

View timrogers's full-sized avatar

Tim Rogers timrogers

View GitHub Profile
{% css_asset_tag global %}
- /_assets/foo.css
- /_assets/bar.css
{% endcss_asset_tag %}
{% javascript_asset_tag global %}
- /_assets/foo.js
- /_assets/bar.js
{% endjavascript_asset_tag %}
@timrogers
timrogers / gist:5199100
Created March 19, 2013 19:03
A monkeypatch for Object in Ruby which is basically the opposite of Array#include?. You can take an any object and call "in?" on it with an array as the parameter, and it will check whether the subject object is in that array.
class Object
def in?(array)
# Returns true if the Object that this is called on is included in
# the array passed in, otherwise returns false
array.include? self
end
end
@timrogers
timrogers / confirm.php
Created April 22, 2013 11:15
Setting account details in the GoCardless PHP library
<?php
require_once('GoCardless.php');
$account_details = array(
'app_id' => 'DUMMY_APP',
'app_secret' => 'INSERT_APP_SECRET_HERE',
'merchant_id' => 'WOQRUJU9OH2HH1',
'access_token' => 'INSERT_MERCHANT_ACCESS_TOKEN'
);
@timrogers
timrogers / exceptions.php
Created April 25, 2013 08:55
An exposé of the additional methods available on the GoCardless_ApiException class
<?php
require('lib/GoCardless.php');
$account_details = array(
"app_id" => "XXX",
"app_secret" => "XXX",
"access_token" => "XXX"
);
GoCardless::set_account_details($account_details);
<?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'
);
{ "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" }
@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
<?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));
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.
@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'