Skip to content

Instantly share code, notes, and snippets.

View andrewpthorp's full-sized avatar
🎯

Andrew Thorp andrewpthorp

🎯
View GitHub Profile
@andrewpthorp
andrewpthorp / webhook_handler.php
Created November 22, 2013 16:58
Stripe PHP Webhooks.
try {
$response = Stripe_Event::retrieve($event_json->id);
// If you get to this point, you have a valid Stripe Event.
// You will do something with the response, which will be a Stripe_Event.
} catch (Stripe_InvalidRequestError $e) {
// If you get to this point, you tried to request an invalid Stripe_Event.
@andrewpthorp
andrewpthorp / gist:7555002
Created November 20, 2013 00:12
curl delete card
curl https://api.stripe.com/v1/customers/cus_2oZkg25nCQC4SO/cards/card_2wpfNByDV44zuO \
-u <YOUR_TEST_SECRET>: \
-X DELETE
@andrewpthorp
andrewpthorp / ability.rb
Created April 19, 2013 18:53
Best Ability Ever!
class Ability
include CanCan::Ability
def initialize(subject)
can :manage, :all
end
end
@andrewpthorp
andrewpthorp / coderay.css
Created March 11, 2013 13:02
A CodeRay theme to get GitHub style code coloring.
.CodeRay {
background-color: #efefef;
font-family: Monaco, "Courier New", "DejaVu Sans Mono", "Bitstream Vera Sans Mono", monospace;
color: #000;
margin-bottom: 14px;
}
.CodeRay pre {
margin: 0px;
padding: 1em;
@andrewpthorp
andrewpthorp / some_rspec.rb
Created December 13, 2012 04:38
Give me your opinions:
# Explicit contexts
describe ".some_method?" do
context "when <condition is met>" do
it "should be true" do
@foo.condition = "met"
@foo.should be_some_method
end
end
context "when <condition is not met>" do
@andrewpthorp
andrewpthorp / Dispatcher.java
Created August 21, 2012 17:37
Java Ignore SSL Cert Errors
String url = "https://path/to/url/service";
HttpClient client = new HttpClient();
PostMethod method = new PostMethod(url);
// Test whether to ignore cert errors
if (ignoreCertErrors){
TrustManager[] trustAllCerts = new TrustManager[]{
new X509TrustManager(){
public X509Certificate[] getAcceptedIssuers(){ return null; }
public void checkClientTrusted(X509Certificate[] certs, String authType) {}
@andrewpthorp
andrewpthorp / index.html
Created May 18, 2012 15:51
Hammer Questions
<div id="wrapper">
<div id="hammertime-inside-wrapper">This is a test</div>
</div>
<script>
$(function(){
$("#wrapper").hammer();
$("#hammertime-inside-wrapper").bind("tap", function(e) { console.log(e); });
});
</script>
@andrewpthorp
andrewpthorp / config.js
Created March 20, 2012 15:06
RequireJS Questions - Extracted from backbone-boilerplate
// Set the require.js configuration for your application.
require.config({
// Initialize the application with the main application file
deps: ["main"],
paths: {
// JavaScript folders
libs: "../assets/js/libs",
plugins: "../assets/js/plugins",
@andrewpthorp
andrewpthorp / app.js
Created March 12, 2012 18:17
PGExternalScreen Error
function resultHandler(result){
alert(result);
}
function errorHandler(error){
alert("ERROR: "+ error);
}
$(document).on("deviceready", function(){
PGExternalScreen.setupScreenConnectionNotificationHandlers( resultHandler, errorHandler );
@andrewpthorp
andrewpthorp / myapp.js
Created March 2, 2012 16:20
Underscore.js errors
MYAPP = {
fetchTemplate: function(path, done) {
window.JST = window.JST || {};
// Should be an instant synchronous way of getting the template, if it
// exists in the JST object.
if (JST[path]) {
return done(JST[path]);
}