Skip to content

Instantly share code, notes, and snippets.

View alphanumeric0101's full-sized avatar

Alexander Folk alphanumeric0101

View GitHub Profile
@alphanumeric0101
alphanumeric0101 / alertTaskers.js
Last active September 22, 2017 18:03
sending texts via twilio to taskers when a new shift is posted
var textClient = require('twilio')(process.env.TWILIO_ACCOUNT_SID, process.env.TWILIO_AUTH_TOKEN)
var sendText = textClient.messages.create({
to: phone,
from: taskiPhone,
body: messageBody
}, function (err, message) {
if (err) {
debug('Twilio error!')
console.log('texting error: ' + messageBody.length + ' chars')
console.log(err)
[
{
"user": "Veronica Letourneau",
"email": "veronicaletourneau@hotmail.com",
"referred": "cqbanks14@gmail.com",
"date": "9/8/2017",
"status": "sent",
"converted": false
},
{
@alphanumeric0101
alphanumeric0101 / payments.js
Created May 19, 2017 16:09
Sample of creating a stripe charge
// generate the payment blob we will base the charge on
this.createJobBrief = function(shift, worker, confirmedShiftData, employer, employerReview) {
// in the case of ch_1AGu3MCOsXOJGjx5HT3TBu2n, shift.pay was 16$
// employers can update the hours worked, hence confirmedShiftData
// there's an excessive amount of coercing to Number() here...
// I should probably switch these to Math.round() ;P
let amount_owed = Number((Number(shift.pay) * Number(confirmedShiftData.updatedHours)).toFixed(2))
let taxes = Number((Number(amount_owed) * 0.05).toFixed(2));
let fee = Number(Number(amount_owed * 0.20).toFixed(2));