Skip to content

Instantly share code, notes, and snippets.


Tom Maiaroto tmaiaroto

View GitHub Profile
tmaiaroto / get_raw_sql.ts
Created Jun 24, 2020 — forked from slavivanov/get_raw_sql.ts
Get generated SQL query from Sequelize
View get_raw_sql.ts
import * as Sequelize from "sequelize";
import uuidv1 = require("uuid/v4");
import { SequelizeModelStatic } from "./sequelize";
import * as pLimit from "p-limit";
import _ = require("lodash");
* Get generated SQL query from sequelize. Returns a promise that:
* 1. Adds a hook that receives the prepared options from Sequelize
* - Since hooks work on the whole model,
View getIEVersion.js
// Looks at User Agent to determine if IE and which version
function GetIEVersion() {
var sAgent = window.navigator.userAgent;
var idx = sAgent.indexOf("MSIE");
var versionNumber = 0;
// If IE, return version number.
if (idx) {
try {
versionNumber = parseInt(sAgent.substring(idx+ 5, sAgent.indexOf(".", idx)));
tmaiaroto / material-ui-flexible-fixed-header-table.js
Created Mar 16, 2020 — forked from antonfisher/material-ui-flexible-fixed-header-table.js
React.js Material-UI Table component with flexible height and fixed header
View material-ui-flexible-fixed-header-table.js
* React.js Material-UI Table and TableRow components with flexible height and fixed header
* - fixes "jumping" scrolling bar in WebKit browsers
* - shows permanent scrolling bar for other browsers
* Usage: import this Table and TableRow component instead of
* 'material-ui/Table' and 'material-ui/TableRow' component
import React, {PropTypes} from 'react';
tmaiaroto /
Created Dec 30, 2019 — forked from tzmartin/
Embedded File Viewer: Google Drive, OneDrive

Office Web Apps Viewer

('.ppt' '.pptx' '.doc', '.docx', '.xls', '.xlsx')[OFFICE_FILE_URL]

<iframe src='[OFFICE_FILE_URL]' width='px' height='px' frameborder='0'>

OneDrive Embed Links

tmaiaroto / gcp-cloud-build-multiple.yaml
Created Aug 10, 2019
GCP Cloud Build - multiple builds from directories
View gcp-cloud-build-multiple.yaml
# If a directory has a cb-deploy.yaml file, it will run for CD
- name: ''
entrypoint: 'bash'
- '-c'
- |
for d in */; do
if [[ ! -f "${config}" ]]; then
tmaiaroto / verify_cognito_jwt.go
Last active Apr 12, 2018
Example Cognito JWT Verification
View verify_cognito_jwt.go
// The following pakcages are used by the function below
// ParseAndVerifyJWT will parse and verify a JWT, if an error is returned the token is invalid,
// only a valid token will be returned.
// To verify the signature of an Amazon Cognito JWT, search for the key with a key ID that matches
// the key ID of the JWT, then use libraries to decode the token and verify the signature.
tmaiaroto / callback.go
Created Apr 12, 2018
Example Aegis Cognito Callback Handler
View callback.go
// Handle oauth2 callback, will exchange code for token
func cognitoCallback(ctx context.Context, d *aegis.HandlerDependencies, req *aegis.APIGatewayProxyRequest, res *aegis.APIGatewayProxyResponse, params url.Values) error {
// Exchange code for token
tokens, err := d.Services.Cognito.GetTokens(req.QueryStringParameters["code"], []string{})
if err != nil {
log.Println("Couldn't get access token", err)
res.JSONError(500, err)
} else {
// verify the token
_, err := d.Services.Cognito.ParseAndVerifyJWT(tokens.IDToken)
tmaiaroto / cognito_trigger_types.go
Last active Apr 5, 2018
Cognito Lambda Trigger Types
View cognito_trigger_types.go
// CognitoTriggerCallerContext contains information about the caller (should be the same for all triggers)
type CognitoTriggerCallerContext struct {
AWSSDKVersion string `json:"awsSdkVersion"`
ClientID string `json:"clientId"`
// CognitoTriggerCommon contains common data from events sent by AWS Cognito (should be the same for all triggers)
type CognitoTriggerCommon struct {
tmaiaroto / main.go
Created Mar 28, 2018
Go Lambda GeoIP
View main.go
package main
import (
aegis ""
tmaiaroto / Dockerfile
Last active Jun 30, 2022
WordPress on Amazon ECS
View Dockerfile
FROM alpine:3.3
MAINTAINER Tom Maiaroto <>
# Install packages
RUN apk --update --repository add \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
php7 \