Skip to content

Instantly share code, notes, and snippets.

View josephspurrier's full-sized avatar

Joseph Spurrier josephspurrier

View GitHub Profile
@josephspurrier
josephspurrier / values_pointers.go
Last active September 28, 2023 03:16
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 / openswan-aws.md
Last active September 27, 2023 12:12
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 / Dockerfile
Created December 3, 2020 02:14
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 / main.go
Last active March 8, 2023 08:52
OpenAI/ChatGPT Terminal in Go
View main.go
package main
import (
"bufio"
"fmt"
"log"
"os"
"strings"
)
@josephspurrier
josephspurrier / addimport.go
Last active October 28, 2022 14:34
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 / aescmd.go
Created December 23, 2014 07:11
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 / loadCSV.php
Last active September 28, 2022 10:34
Parse a CSV file in PHP, remove hidden characters, escape fields to prepare for MySQL, and return an associative array.
View loadCSV.php
// Auto detect line endings
ini_set('auto_detect_line_endings', true);
function loadCSV($file)
{
// Create an array to hold the data
$arrData = array();
// Create a variable to hold the header information
$header = NULL;
@josephspurrier
josephspurrier / .bash_profile
Last active September 13, 2022 21:25
macOS Bash Profile
View .bash_profile
#################################################################################
#
# Bash Configurations and Aliases for OS X
#
# Latest: https://gist.github.com/josephspurrier/acf7327726df6587a56ff2c2062314fa
# This was modified so it can be included in your ~/.zshrc file with the command:
# source ~/.bash_profile
#
# It's recommended to use oh-my-zsh:
# sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"
@josephspurrier
josephspurrier / sshclient.go
Last active September 10, 2022 02:23
Golang SSH Client
View sshclient.go
package main
import (
"bufio"
"io/ioutil"
"os/signal"
//"syscall"
"fmt"
"log"
"os"
@josephspurrier
josephspurrier / main.go
Last active May 29, 2022 14:32
Font Tester
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"
)