Skip to content

Instantly share code, notes, and snippets.

View rjaus's full-sized avatar

Riley James rjaus

View GitHub Profile
@rjaus
rjaus / sequelize-models-json-jsonb.js
Created August 4, 2021 05:58
Sequelize JSON vs JSONB with Postgres
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Service extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
@rjaus
rjaus / sequelize-model-sync.js
Created August 4, 2021 05:47
sequelize model & sync
'use strict';
const {
Model
} = require('sequelize');
module.exports = (sequelize, DataTypes) => {
class Service extends Model {
/**
* Helper method for defining associations.
* This method is not a part of Sequelize lifecycle.
* The `models/index` file will call this method automatically.
@rjaus
rjaus / appstore.md
Last active April 1, 2021 09:24
What's going on in the app store?!

What's going on in the app store??

my mail is rj (AT) rileyjames.co

@rjaus
rjaus / xero.json
Created April 10, 2018 01:44
Xero Config JSON file (for node)
{
"userAgent" : "Riley Tierion Example",
"consumerKey": "FUTDJTYEWGSKVVCKKWQFJTDJSURDEY",
"consumerSecret": "DHSURTYDPDXOKAZ6DUIQRGTJDTUYFD",
"privateKeyPath": "./privatekey.pem",
"webhookKey": "ByxdfkFMZd0+wLsd1UV/yF/+oMzhhTD5PiETFidppgY7x6v7woYwutDiyijQKXg2m2WFJDTSlaykJOh910xWtg=="
}
@rjaus
rjaus / index.rb
Created March 9, 2018 00:54
Xero Webhooks ITR Example for Ruby Sintra
require 'sinatra'
require 'base64'
require 'openssl'
post '/webhook' do
payload = request.body.read
key = "WEBHOOKS_KEY"
signature = Base64.encode64(OpenSSL::HMAC.digest(OpenSSL::Digest.new('sha256'), key, payload)).strip()
@rjaus
rjaus / s3-xero-attachment-upload.js
Created February 14, 2018 01:14
Read s3 bucket object and upload to Xero as attachment example code
// AWS s3
const aws = require('aws-sdk');
aws.config.loadFromPath('./aws.json');
aws.config.update({region:'us-east-1'});
const s3 = new aws.S3();
// Xero client
const xero = require('xero-node')
const fs = require('fs')
const config = require('./xero.json')
@rjaus
rjaus / tls-version-test.rb
Created February 14, 2018 00:16
Find out which TLS version your ruby install supports, utilising: https://www.howsmyssl.com/s/api.html
require "net/http"
require "uri"
require "json"
uri = URI.parse("https://www.howsmyssl.com/a/check")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
resp = JSON.parse(http.request(Net::HTTP::Get.new(uri.request_uri)).body)
puts JSON.pretty_generate(resp)
@rjaus
rjaus / express.js
Last active January 23, 2018 06:47
Xero webhooks Express JS example
'use strict'
const express = require('express')
const bodyParser = require('body-parser')
const crypto = require('crypto')
// Replace with your Xero Webhook Key
const xero_webhook_key = 'XERO_WEBHOOK_KEY'
// Create a new instance of express
@rjaus
rjaus / hapi.js
Created January 23, 2018 05:17
Node Hapi JS gist
'use strict'
const hapi = require('hapi')
const crypto = require('crypto')
// Set the server to launch on localhost:3000
const server = hapi.server({ host: 'localhost', port: 3000 })
// Replace with your Xero Webhook Key
const xero_webhook_key = 'XERO_WEBHOOK_KEY'