Skip to content

Instantly share code, notes, and snippets.

Avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@josephspurrier
josephspurrier / openswan-aws.md
Last active Jul 1, 2022
Set up VGW on AWS with OpenSwan
View openswan-aws.md

Set up VGW on AWS with OpenSwan

You will need 2 VPCs. The Internet VPC will have the Internet Gateway and the OpenSwan EC2 instance. The Project VPC will have your application or Kubernetes cluster.

Internet VPC

  • VPC CIDR: 10.230.30.0/24
  • Private Subnet: 10.230.30.128/25 - Route Table with 0.0.0.0/0 to NAT
  • Public Subnet: 10.230.30.0/25 - Route Table with 0.0.0.0/0 to IGW, 10.224.36.0/23 to OpenSwan Instance
  • NAT Gateway in the public subnet with an IP of 52.15.61.171
@josephspurrier
josephspurrier / values_pointers.go
Last active Jun 30, 2022
Golang - Asterisk and Ampersand Cheatsheet
View values_pointers.go
/*
********************************************************************************
Golang - Asterisk and Ampersand Cheatsheet
********************************************************************************
Also available at: https://play.golang.org/p/lNpnS9j1ma
Allowed:
--------
p := Person{"Steve", 28} stores the value
@josephspurrier
josephspurrier / addimport.go
Last active Jun 14, 2022
Add Import using ast in Go
View addimport.go
// Source: https://gitlab.pro/googlesource/tools/blob/ae534bcb6ccdd13487d0491c2194d10ebcd30ff3/astutil/imports.go
// Source: https://golang.org/src/go/doc/example.go#L262
package main
import (
"bytes"
"fmt"
"go/ast"
"go/parser"
@josephspurrier
josephspurrier / sshclient.go
Last active May 31, 2022
Golang SSH Client
View sshclient.go
package main
import (
"bufio"
"io/ioutil"
"os/signal"
//"syscall"
"fmt"
"log"
"os"
View main.go
// Package main can be used to see how a font looks in your IDE.
// Preference: https://github.com/gaplo917/Ligatured-Hack
// VSCode Settings: https://gist.github.com/josephspurrier/15a74871d65926c7415b55fe4b8d2946#file-settings-json
package main
import (
"fmt"
"net/http"
)
@josephspurrier
josephspurrier / extensions.json
Last active May 29, 2022
Visual Studio Code Settings
View extensions.json
{
"recommendations": [
"dbaeumer.vscode-eslint",
"golang.go",
"yzhang.markdown-all-in-one",
"equinusocio.vsc-material-theme-icons",
"gruntfuggly.todo-tree",
"redhat.vscode-yaml"
]
}
@josephspurrier
josephspurrier / Dockerfile
Created Dec 3, 2020
AWS Lambda Container in Go
View Dockerfile
FROM public.ecr.aws/lambda/go:1
# Copy function code
COPY hello ${LAMBDA_TASK_ROOT}
# Set the CMD to your handler (could also be done as a parameter override outside of the Dockerfile)
CMD [ "hello" ]
@josephspurrier
josephspurrier / aescmd.go
Created Dec 23, 2014
Golang - Encrypt, Decrypt, File Read, File Write, Readline
View aescmd.go
package main
import (
"bufio"
"crypto/aes"
"crypto/cipher"
"crypto/rand"
"fmt"
"io"
"io/ioutil"
@josephspurrier
josephspurrier / structs_interface.go
Last active May 12, 2022
Golang - Understand Structs and Interfaces
View structs_interface.go
// Also available at: https://play.golang.org/p/yTTpB5gB6C
package main
import (
"fmt"
)
// *****************************************************************************
// Example 1 - Struct vs Struct with Embedded Type
@josephspurrier
josephspurrier / godownload.go
Created Sep 20, 2015
File Downloader in Golang
View godownload.go
package main
import (
"io/ioutil"
"log"
"net/http"
"os"
"path/filepath"
"strings"
)