This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Connect to local PG instance | |
psql -U postgres | |
# Show databases | |
\l | |
# Drop existing database and recreate | |
drop database DBNAME | |
create database DBNAME |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Place a buy order | |
function buyOrder(orderSize, currentPrice){ | |
const args = { | |
'product_id': 'ETH-USD', | |
'type': 'market', | |
'side': 'buy', | |
'size': orderSize | |
} | |
gdaxClient.buy(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Send SMS notification | |
function sendSMS(message){ | |
twilioClient.messages.create({ | |
to: process.env.MY_NUMBER, | |
from: process.env.TWILIO_SMS_NUMBER, | |
body: message | |
}) | |
.then(msg => { | |
// Log the message from Twilio | |
console.log(msg); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Check the price of ETH to determine how much to buy | |
gdaxClient.getProductTicker( | |
'ETH-USD' | |
) | |
.then(data => { | |
// Determine what $10 of ETH costs | |
const price = (10/data.price); | |
// Return smallest unit available for purchase | |
const orderSize = price.toString().substr(0,10); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ... the previous initialization code above | |
// Declare Lambda handler | |
const handler = (event, context, callback) => { | |
// Check the price of ETH to determine how much to buy | |
// Place a buy order | |
// Send an SMS notification |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Use dotenv to load environment variables | |
require('dotenv').config(); | |
// Load Twilio and GDAX | |
const twilio = require('twilio'); | |
const gdax = require('gdax'); | |
// Set up GDAX for buying crypto | |
const gdaxClient = new gdax.AuthenticatedClient( | |
process.env.GDAX_API_KEY, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get the balance transactions from the payout for the payout transactions view | |
@txns = Stripe::BalanceTransaction.list( | |
{ | |
payout: params[:id], # The ID of the payout you want transactions for | |
expand: ['data.source.source_transfer'], # Expand the source_transfer for extra detail | |
limit: 100 | |
}, | |
{ stripe_account: current_user.stripe_account } | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Last 100 payouts from the custom account to their bank account | |
@payouts = Stripe::Payout.list( | |
{ | |
limit: 100, | |
expand: ['data.destination'] # Get some extra detail about the bank account | |
}, | |
{ stripe_account: current_user.stripe_account } # Again, authenticating with the ID of the connected account | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="row"> | |
<div class="col-md-12"> | |
<table class="table table-bordered table-striped table-hover"> | |
<thead> | |
<tr> | |
<th>Payment ID</th> | |
<th>Amount</th> | |
<th>Net</th> | |
<th>Created</th> | |
<th>Actions</th> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Last 100 charges | |
payments = Stripe::Charge.list( | |
{ | |
limit: 100, # The number of charges to retrieve (between 1 and 100) | |
expand: ['data.source_transfer', 'data.application_fee'] # Expand other objects for additional detail | |
}, | |
{ stripe_account: current_user.stripe_account } # The Stripe ID of the user viewing the dashboard | |
) |
NewerOlder