Skip to content

Instantly share code, notes, and snippets.

Tom Maiaroto tmaiaroto

Block or report user

Report or block tmaiaroto

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@tmaiaroto
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
steps:
- name: 'gcr.io/cloud-builders/gcloud'
entrypoint: 'bash'
args:
- '-c'
- |
for d in */; do
config="${d}cb-deploy.yaml"
if [[ ! -f "${config}" ]]; then
@tmaiaroto
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
// https://github.com/dgrijalva/jwt-go
// https://github.com/lestrrat/go-jwx
// 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
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
tmaiaroto / cognito_trigger_types.go
Last active Apr 5, 2018
Cognito Lambda Trigger Types
View cognito_trigger_types.go
// https://docs.aws.amazon.com/cognito/latest/developerguide/cognito-user-pools-lambda-trigger-syntax-shared.html
// 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
tmaiaroto / main.go
Created Mar 28, 2018
Go Lambda GeoIP
View main.go
package main
import (
"github.com/oschwald/geoip2-golang"
"github.com/fatih/structs"
aegis "github.com/tmaiaroto/aegis/framework"
"net"
"context"
"net/url"
"log"
@tmaiaroto
tmaiaroto / Dockerfile
Last active May 8, 2019
WordPress on Amazon ECS
View Dockerfile
FROM alpine:3.3
MAINTAINER Tom Maiaroto <tom@outdoorsy.co>
# Install packages
RUN apk --update --repository http://dl-3.alpinelinux.org/alpine/edge/main add \
freetype-dev \
libjpeg-turbo-dev \
libpng-dev \
libwebp-dev \
php7 \
@tmaiaroto
tmaiaroto / pre-commit
Last active Jul 30, 2016
A Go Commit Hook for Less Future Headaches
View pre-commit
#!/bin/bash
#
# Check a "few" things to help write more maintainable Go code.
#
# OK, it's fairly comprehensive. So simply remove or comment out
# anything you don't want.
#
# Don't forget to install (go get) each of these tools.
# More info at the URLs provided.
#
@tmaiaroto
tmaiaroto / image-to-canvas.js
Created Aug 7, 2015
Render image to Canvas in Node.js example
View image-to-canvas.js
request({url: opts.url, method: 'GET', headers: { 'user-agent': opts.userAgent}, encoding: null}, function (error, response, body) {
if(!error && response.statusCode == 200) {
var img = new Image
, canvas = new Canvas
, ctx = canvas.getContext('2d');
img.onload = function() {
canvas.width = img.width;
canvas.height = img.height;
ctx.fillStyle = 'white';
@tmaiaroto
tmaiaroto / Gruntfile.js
Created Jul 2, 2015
Gruntfile for working with Hugo
View Gruntfile.js
module.exports = function(grunt) {
require('matchdep').filterDev('grunt-*').forEach(grunt.loadNpmTasks);
grunt.initConfig({
shell: {
options: {
stdout: true
},
server: {
View install-comodo-ssl-cert-for-nginx.rst

Setting up a SSL Cert from Comodo

I use Namecheap.com as a registrar, and they resale SSL Certs from a number of other companies, including Comodo.

These are the steps I went through to set up an SSL cert.

Purchase the cert

You can’t perform that action at this time.