Skip to content

Instantly share code, notes, and snippets.

View thorwebdev's full-sized avatar
🔨
building

Thor 雷神 Schaeff thorwebdev

🔨
building
View GitHub Profile
@thorwebdev
thorwebdev / avg_fare_amount.sql
Last active August 29, 2015 14:11
Calculate the average fare amount for each area. Exclude fares with value 0.
SELECT
pickup_polyId,
SUM(fare_amount)/COUNT(*) AS average_fare,
COUNT(*) AS no_of_trips
FROM
[nyctaximap:dataflow.nyc_output_join_fare_distinct]
WHERE
fare_amount!=0
GROUP BY
pickup_polyId
@thorwebdev
thorwebdev / no_of_trips.sql
Created December 15, 2014 20:34
Calculate the number of trips that started in a certain area.
SELECT
pickup_polyId,
COUNT(*) AS no_of_trips
FROM
[nyctaximap:dataflow.nyc_output_join_fare_distinct]
GROUP BY
pickup_polyId
ORDER BY
no_of_trips DESC;
@thorwebdev
thorwebdev / avg_fare_amount.sql
Created December 15, 2014 20:43
These are some interesting queries you can run on this BigQuery table: https://bigquery.cloud.google.com/table/nyctaximap:dataflow.nyc_output_join_fare_distinct . The data has been aggregated using Google Cloud Dataflow. For more background information on how the data has been processed see: https://googlecloudplatform.blogspot.com
SELECT
pickup_polyId,
SUM(fare_amount)/COUNT(*) AS average_fare,
COUNT(*) AS no_of_trips
FROM
[nyctaximap:dataflow.nyc_output_join_fare_distinct]
WHERE
fare_amount!=0
GROUP BY
pickup_polyId
<div id="log"></div>
<script type="text/javascript" src="https://dl.dropboxusercontent.com/sh/oexkzj4z2zzs02d/AADB02b-GUnvoxDr9EvD61yZa/adyen.encrypt.nodom.min.js"></script>
<script src="https://js.braintreegateway.com/js/braintree-2.22.2.min.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<script type="text/javascript">
(function() {
//Copy your public keys here
var stripePK = "pk_test_jg6c4WIhuzDD7kcYW0Nu7T6r";
var adyenPK = "10001|B01FDAF7CD9B73F094906C5B078963FAAE57AFC619D561EFC784EA505EC6CCA94AF0CA3F97CA9CFC04E2151F39A461BF45DE7CB7DEA46C56EB3420502DA69BF4A6FFA21464D46861051367A26422EF3A9E6288F821CB47E8F88B4C2D9BEEF96AF0686E6F1C4171C5B5BD1C80E23A112BE57B990389E783B8F614F07CDBBBB68D7175F0282C7E0FA985D881E2A9EB6B54BE231D5733912A217F92D5952C6AA1ECF1765F11337441502FFCDD9B9DD3F2A40F98E96DDF51E60B06D8987D3622EB119AF7360055626DC99E6555724FBBFC1F985DB506E16E6A9B040959799C3C6ADD7F21C97493D7823CE7A234491377165815CE075ED55375F772F101DA0335D70D";
var brainTreePK
@thorwebdev
thorwebdev / stripe_one_time_charge.php
Last active August 11, 2019 23:36
Best practice example for creating one time charges using Stripe.js and Stripe's PHP bindings without creating customer objects.
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>One Time Charge</title>
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
</head>
<body>
@thorwebdev
thorwebdev / README.md
Last active May 15, 2016 16:45 — forked from caseywatts/Gemfile
Sinatra + Stripe on Cloud9

Cloud 9 - Sinatra + Stripe

Setting Up Cloud9

  • Go to c9.io and log in
  • Create a new workspace
    • Workspace name = hello-stripe
    • Clone from Git or Mercurial URL = https://gist.github.com/f71ef966f488ab8fd984e0791cf96c07.git
    • (everything else at defaults)
@thorwebdev
thorwebdev / app.rb
Last active May 15, 2016 17:38
Advanced Stripe Integration Training: Customers + Subscriptions
require 'sinatra'
require 'sinatra/reloader' if development?
require "stripe"
Stripe.api_key = "sk_test_***"
get '/' do
# Output index.erb template to user
erb :index
end
<form action="/charge" method="POST">
<script
src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="pk_test_****"
data-amount="2000"
data-name="schaeffonline.de"
data-description="2 widgets"
data-image="https://cdn.shopify.com/s/files/1/0302/2969/products/great-cookie-m_and_m-cookie-03_1024x1024.jpg"
data-locale="auto"
data-zip-code="true"
post '/charge' do
# Output the params hash with the values from Checkout in the bash
puts params.inspect
# Store Stripe Token and Customer Email Address in local variables
token = params[:stripeToken]
email = params[:stripeEmail]
# Create a new Customer
# Store the Response in a local variable
get '/customers' do
# Get a list of ten customers
customers = Stripe::Customer.all(:limit => 10)
# Store customer list in an instance variable
@c = customers.data
#Output customers.erb template to user
erb :customers
end