Skip to content

Instantly share code, notes, and snippets.

View dsandor's full-sized avatar

David Sandor dsandor

View GitHub Profile
@dsandor
dsandor / go.mod
Created January 15, 2024 13:22
go.mod
module gitlab.com/examples55/golang-api-2024
go 1.20
@dsandor
dsandor / template.yaml
Created January 15, 2024 13:11
template.yaml
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: CloudFormation Template for standing up aws resources for the API.
Globals:
Function:
Handler: bootstrap
Runtime: provided.al2
Timeout: 10
MemorySize: 128
@dsandor
dsandor / route.go
Created May 4, 2022 13:55
Websocket Lambda Route Handler in Golang
type DefaultResponse struct {
StatusCode int `json:"statusCode"`
Body string `json:"body"`
IsBase64Encoded bool `json:"isBase64Encoded"`
Headers struct {
ContentType string `json:"content-type"`
} `json:"headers"`
}
func (d *dependencies) list(ctx context.Context, websocketEvent events.APIGatewayWebsocketProxyRequest) (DefaultResponse, error) {
@dsandor
dsandor / snippte-template.yaml
Created May 4, 2022 13:38
AWS API Gateway WebSocket route configured for two way request/response.
########## Default Route ($default) Function and APIGW Config ############
DefaultFunction:
Type: AWS::Serverless::Function
Properties:
CodeUri: default/
Handler: bootstrap # note, this is the name of the executable output from the Makefile.
Runtime: provided.al2
Architectures: [ arm64 ]
Policies:
@dsandor
dsandor / auth.go
Created May 4, 2022 12:52
Golang AWS API Gateway Lambda Authorizer
package main
import (
"context"
"fmt"
"github.com/aws/aws-lambda-go/events"
)
func generatePolicy(principalId, effect, resource string) events.APIGatewayCustomAuthorizerResponse {
authResponse := events.APIGatewayCustomAuthorizerResponse{PrincipalID: principalId}
@dsandor
dsandor / gist:04b844e441ab6001cc839c03e619407d
Created April 22, 2022 12:48 — forked from devinodaniel/gist:8f9b8a4f31573f428f29ec0e884e6673
Generate SSH RSA Private/Public Key pair with Golang
// This shows an example of how to generate a SSH RSA Private/Public key pair and save it locally
package main
import (
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/pem"
"golang.org/x/crypto/ssh"
@dsandor
dsandor / index.js
Last active November 13, 2020 21:17
test
#!/usr/bin/env node
const fs = require('fs');
const { processTemplate } = require('./processor')
function run() {
const templateFilePath = '../.stackery/template.yaml';
const templateExists = fs.existsSync(templateFilePath);
if (!templateExists) {
console.log('Could not find template file:', templateFilePath, 'cwd:', process.cwd());
@dsandor
dsandor / template.yaml
Created August 13, 2020 12:18
Example S3 -> SNS -> Lambda SAM template.
AWSTemplateFormatVersion: 2010-09-09
Transform: AWS::Serverless-2016-10-31
Resources:
Bucket:
Type: AWS::S3::Bucket
Properties:
BucketName: !Sub my-bucket-${AWS::AccountId}
NotificationConfiguration:
TopicConfigurations:
- Event: s3:ObjectCreated:*
block_z = 22;
block_y = 47;
block_x = 36;
cylinder_cutout_depth = 25;
difference() {
cube([block_x, block_y, block_z], center=true);
color("blue") translate([0,0,3]) cylinder(r=14.1, h=cylinder_cutout_depth, $fn=100, center=true);
color("red") translate([5.7,0,6]) cube([17,18,30.5], center=true);
@dsandor
dsandor / remove_mcafee.md
Last active April 15, 2020 13:00 — forked from pjobson/remove_mcafee.md
OSX McAfee Removal

Removal of McAfee from OSX

Note: This was written in 2015, it may be out of date now.

There are a lot of commands here which I use sudo if you don't know what you're doing with sudo, especially where I rm you can severely screw up your system.

There are many reasons which you would want to remove a piece of software such as McAfee, such as not wanting it to hammer your CPU during work hours which seems like primetime for a virus scan.

I intend this to be a living document, I have included suggestions from peoples' replies.