Skip to content

Instantly share code, notes, and snippets.

@amfeng
amfeng / callback.html
Last active February 1, 2020 17:04
Stripe OAuth Example -- Python
<!doctype html>
<head>
<title>Stripe OAuth Example</title>
</head>
<body>
{{ token }}
</body>
</html>
@amfeng
amfeng / index.php
Last active August 8, 2022 19:33
Stripe OAuth Example -- PHP
<?php
define('CLIENT_ID', 'YOUR_CLIENT_ID');
define('API_KEY', 'YOUR_API_KEY');
define('TOKEN_URI', 'https://connect.stripe.com/oauth/token');
define('AUTHORIZE_URI', 'https://connect.stripe.com/oauth/authorize');
if (isset($_GET['code'])) { // Redirect w/ code
$code = $_GET['code'];
@amfeng
amfeng / callback.erb
Last active August 8, 2022 19:33
Stripe OAuth Example -- Ruby
<!doctype html>
<head>
<title>Stripe OAuth Example</title>
</head>
<body>
<%= @access_token %>
</body>
</html>
@amfeng
amfeng / voting.rb
Created November 10, 2011 17:53
CS194-17: Voting Interfaces
# @abstract VoteCounterProtocol is the interface for vote counting.
# A vote counting protocol should subclass VoteCounterProtocol.
module VoteCounterProtocol
state do
# On the client side, tell the vote counter to start counting votes
# for a specific ballot.
# @param [Object] ballot_id the unique id of the ballot
# @param [Number] num_votes the number of votes that will be cast (this number will remain static throughout the vote)
interface input :begin_vote, [:ballot_id] => [:num_votes]
# Want to have Membership separate, so can plug in different Membership modules on the fly
# Check number of members in the beginning, when find winner, consult current state of member table OR have vote_status = currently voting
module VoteMasterProtocol
state do
interface input :begin_vote, [:ballotid, :content, :ratio]
interface output, :result, [:ballotid, :result]
end
end
package edu.berkeley.cs
package scads
package piql
package gradit
import storage.ScadsCluster
import avro.marker._
import org.apache.avro.util._
ENTITY book_lines
{
int book_line_id,
string line,
int source,
int linenum,
int created_at,
int updated_at
PRIMARY(linenum, source)
}
ENTITY book_lines
{
int book_line_id,
string line,
int source,
int linenum,
int created_at,
int updated_at
PRIMARY(linenum, source)
}
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>edu.berkeley.cs.scads</groupId>
<artifactId>scadrclient</artifactId>
<packaging>jar</packaging>
<version>2.0-SNAPSHOT</version>
<name>SCADR Client Library</name>
<parent>
<groupId>edu.berkeley.cs.scads</groupId>
ENTITY book_lines
{
int book_line_id,
string line,
int source,
int linenum,
int created_at,
int updated_at
PRIMARY(line, source)
}