Skip to content

Instantly share code, notes, and snippets.

View leonkyr's full-sized avatar
🎯
Focus

Leo Kyrpychenko leonkyr

🎯
Focus
View GitHub Profile
@leonkyr
leonkyr / stripe-create-custom-account
Created August 28, 2019 01:48
stripe-create-custom-account
stripe.accounts.create({
country: 'AU',
type: 'custom',
business_type: 'company',
// requested_capabilities: ['card_payments', 'transfers'],
}).then(function (account) {
console.log(JSON.stringify(account, null, 2));
});
@leonkyr
leonkyr / gist:9af76f25e09358dc9721f405b3157cef
Created August 28, 2019 01:48
stripe-create-custom-account
stripe.accounts.create({
country: 'AU',
type: 'custom',
business_type: 'company',
// requested_capabilities: ['card_payments', 'transfers'],
}).then(function (account) {
console.log(JSON.stringify(account, null, 2));
});
@leonkyr
leonkyr / accept-terms
Last active August 28, 2019 01:43
stripe-connect-australia
stripe.accounts.update(accountId, {
metadata: { internal_id: "Tradie-2" },
tos_acceptance: {
date: Math.floor(Date.now() / 1000),
ip: "61.69.124.163" // Assumes you're not using a proxy
}
}).then(function (account) {
console.log(JSON.stringify(account, null, 2));
});
@leonkyr
leonkyr / send-temperature-to-aws-serverless.json
Created August 30, 2018 07:14
A part of serverless json for processing sensor data
functions:
sensorReadings:
name: ${self:provider.stage}-${self:service}-sensor-readings
handler: sensor-readings/index.handler
description: Gets triggered by AWS IoT
timeout: 180
environment:
READING_QUEUE_NAME: ${self:provider.stage}_${self:custom.productName}_reading
READING_DL_QUEUE_NAME: ${self:provider.stage}_${self:custom.productName}_reading_dl
tags:
@leonkyr
leonkyr / process-sensor-data-aws-iot.ts
Created August 30, 2018 07:13
Process sensor data with AWS IoT
require("source-map-support").install();
import { Callback, Handler } from "aws-lambda";
import { baseHandler } from "../shared/lambda";
import logger from "../shared/logger";
import {Models} from "../shared/models";
import {QueueWriter} from "./queue-writer";
const handler: Handler = baseHandler((event: any, callback: Callback) => {
@leonkyr
leonkyr / prepare-the-certs-aws.sh
Created August 30, 2018 07:05
prepare the certificates for AWS IoT
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install nodejs
openssl x509 -in ./CA-roots/VeriSign-Class\ 3-Public-Primary-Certification-Authority-G5.pem -inform PEM -out root-CA.crt
chmod 775 root-CA.crt
npm install aws-iot-device-sdk
@leonkyr
leonkyr / send-temperature-to-aws.js
Last active August 30, 2018 07:12
How to measure temperature and sync to AWS IoT
'use strict';
console.log('Running...');
const SerialPort = require('serialport');
const Readline = require('@serialport/parser-readline')
const portName = '/dev/ttyACM0';
const port = new SerialPort(portName, (err) => {
if (err) {
@leonkyr
leonkyr / slack-auth0.md
Created December 21, 2017 03:46 — forked from woloski/slack-auth0.md
Slack + Auth0
  1. Install the Custom Social Connections extension
  2. Click on the Slack button to install the Slack connection
  3. Enter a Slack Client ID and Secret. To get those go to: https://api.slack.com/apps/new. Fill the fields and pay special attention to the Redirect URI. Enter: https://YOURS.auth0.com/login/callback. See screenshots below.
  4. Click on App Credentials on the left and copy the Client ID and Client Secret and paste them on the Auth0 dashboard
  5. Click Save and then try the flow using the Try button. You should get back the full profile from Slack, including email, team and avatars.

Note: you can change the scopes on the Scope field on Auth0 and include any of these: https://api.slack.com/docs/oauth-scopes

You can now use the Slack connection using any Auth0 client library. Example:

// Restify Server CheatSheet.
// More about the API: http://mcavage.me/node-restify/#server-api
// Install restify with npm install restify
// 1.1. Creating a Server.
// http://mcavage.me/node-restify/#Creating-a-Server
var restify = require('restify');
@leonkyr
leonkyr / call-for-papers-cd-serverless
Created November 1, 2016 07:58
Call for papers JS Talks
I will demonstrate how you can use unit/integration/API testing to support *continuous delivery* for AWS API Gateway and AWS Lambda (backed with other AWS resources)