Skip to content

Instantly share code, notes, and snippets.

View jb41's full-sized avatar

Michal Oblak jb41

View GitHub Profile
require 'json'
require 'stripe'
class ChargeApp < Sinatra::Base
AMOUNT = 300
Stripe.api_key = "SECRET_STRIPE_API_KEY"
post '/charge' do
status = charge_customer(params[:stripeToken, params[:stripeEmail])
<html lang="en">
<head>
<meta charset="utf-8">
<title>CopyFixes.com - Quick fixes of your copywriting from professionals</title>
</head>
<body>
<section>
<h1>CopyFixes.com</h1>
<h2>Quick fixes of your copywriting by professionals</h2>
<button id="stripe-payment-button" class="button-pay">Get 2-months Access for $3</button>
<script src="https://checkout.stripe.com/checkout.js"></script>
<script type="text/javascript">
var handler = StripeCheckout.configure({
key: 'STRIPE_KEY',
locale: 'auto',
token: function(token) {
var data = {
stripeToken: token.id,
function checkSpreadsheetIfPaid(email, has_paid, has_not_paid) {
var sheetsuURI = "https://sheetsu.com/apis/v1.0/c12aec61/search",
params = "?email=" + email;
$.ajax({
url: sheetsuURI+params, dataType: 'json', type: 'GET',
success: has_paid,
error: has_not_paid
});
}
require 'pry'
require 'json'
require 'httparty'
require 'stripe'
class ChargeApp < Sinatra::Base
AMOUNT = 300
Stripe.api_key = "SECRET_STRIPE_KEY"
<html>
<head>
<script src="https://code.jquery.com/jquery-3.0.0-alpha1.js"></script>
</head>
<body>
<ul id="characters-list"></ul>
<script>
var sheetsuUrl = "https://sheetsu.com/apis/v1.0/020b2c0f";
import requests
url = 'https://sheetsu.com/apis/YOUR_API_ID'
data = {"timestamp": "1458819671995", "idea": "wooho"}
r = requests.post(url, json=data)
print r.status_code
print r.json()
@jb41
jb41 / error.rb
Created July 30, 2016 16:49
Dynamically create Error classes
module SheetCRUD
module Error
ERRORS = [
unauthorized: { message: 'Unauthorized.', status: 401 },
limit_exceed: { message: 'Rate limit exceed.', status: 429 },
not_found: { message: 'Not found.', status: 404 }
]
class StandardAPIError < StandardError
angular.module('app').service('Subjucator', [
'$http', function($http) {
return {
get: function(url) {
return $http.get(url);
},
post: function(url, data) {
return $http.post(url, data);
}
};
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<form id="form">
<input type="text" name="name">
<input type="text" name="score">
<button type="submit">submit</button>