Skip to content

Instantly share code, notes, and snippets.

View sierrezinal's full-sized avatar
💭
Listening to Wanderwelle. In Heaven or Las Vegas

Gavin Chun Jin sierrezinal

💭
Listening to Wanderwelle. In Heaven or Las Vegas
  • Vancouver, Canada
View GitHub Profile
@sierrezinal
sierrezinal / aws_delete-default-vpc.sh
Created June 22, 2022 08:46 — forked from jokeru/aws_delete-default-vpc.sh
Script to delete all AWS default VPCs from all regions using AWS CLI
#!/usr/bin/env bash
if [ "$AWS_PROFILE" = "" ]; then
  echo "No AWS_PROFILE set"
  exit 1
fi
for region in $(aws ec2 describe-regions --region eu-west-1 | jq -r .Regions[].RegionName); do
def delimited(filename, delimiter=' ', bufsize=4096):
'''
Creates a generator of word from a file based on a delimiter (by default white space).
'''
buf = ''
with open(filename) as file:
while True:
newbuf = file.read(bufsize)
if not newbuf:
@sierrezinal
sierrezinal / do_cloud-config.init.yaml
Created December 24, 2021 23:00 — forked from c0psrul3/do_cloud-config.init.yaml
Digital Ocean cloud-init / cloud-config / droplet metadata usage
#
#DO droplet metadata intro + for DO-API
# [https://www.digitalocean.com/community/tutorials/an-introduction-to-droplet-metadata#how-to-retrieve-droplet-metadata#digitalocean-api]
#
#intro to cloud-config scripting (source of following examples)
# [https://www.digitalocean.com/community/tutorials/an-introduction-to-cloud-config-scripting]
#
#howto
# [https://www.digitalocean.com/community/tutorials/how-to-use-cloud-config-for-your-initial-server-setup]
#
@sierrezinal
sierrezinal / 20211210-TLP-WHITE_LOG4J.md
Created December 13, 2021 22:55 — forked from SwitHak/20211210-TLP-WHITE_LOG4J.md
BlueTeam CheatSheet * Log4Shell* | Last updated: 2021-12-13 2230 UTC

Security Advisories / Bulletins linked to Log4Shell (CVE-2021-44228)

Errors, typos, something to say ?

  • If you want to add a link, comment or send it to me
  • Feel free to report any mistake directly below in the comment or in DM on Twitter @SwitHak

Other great ressources

@sierrezinal
sierrezinal / kubectl.md
Created November 23, 2021 15:50 — forked from so0k/kubectl.md
Playing with kubectl output

Kubectl output options

Let's look at some basic kubectl output options.

Our intention is to list nodes (with their AWS InstanceId) and Pods (sorted by node).

We can start with:

kubectl get no
@sierrezinal
sierrezinal / echo-server.yml
Created October 18, 2021 07:12 — forked from roock/echo-server.yml
Echo Server Deployment
apiVersion: v1
kind: Namespace
metadata:
name: echoserver
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: echoserver
namespace: echoserver
@sierrezinal
sierrezinal / StreamToString.go
Created September 3, 2021 22:36 — forked from dixudx/StreamToString.go
Golang: io.Reader stream to string or byte slice
import "bytes"
func StreamToByte(stream io.Reader) []byte {
buf := new(bytes.Buffer)
buf.ReadFrom(stream)
return buf.Bytes()
}
func StreamToString(stream io.Reader) string {
buf := new(bytes.Buffer)
@sierrezinal
sierrezinal / crypto.go
Created August 31, 2021 23:32 — forked from miguelmota/crypto.go
Golang SHA256 hash example
package crypto
import (
"crypto/sha256"
)
// NewSHA256 ...
func NewSHA256(data []byte) []byte {
hash := sha256.Sum256(data)
return hash[:]
@sierrezinal
sierrezinal / gist:9397134370c89f7b1571e22db3b04deb
Created August 15, 2021 01:10
Unable to install ingress-nginx into kind cluster
$ kubectl apply --filename
https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/static/provider/kind/deploy.yaml
$ kubectl get pods -n ingress-nginx -l app.kubernetes.io/name=ingress-nginx --watch
NAME READY STATUS RESTARTS AGE
ingress-nginx-admission-create-z5bkg 0/1 ContainerCreating 0 12s
ingress-nginx-admission-patch-cwxsr 0/1 ContainerCreating 0 12s
ingress-nginx-controller-78f889f8b9-sfpw9 0/1 ContainerCreating 0 12s
ingress-nginx-admission-create-z5bkg 0/1 ErrImagePull 0 21s
ingress-nginx-admission-patch-cwxsr 0/1 ErrImagePull 0 21s
@sierrezinal
sierrezinal / rounding_decimals.md
Created May 25, 2021 17:57 — forked from jackiekazil/rounding_decimals.md
How do I round to 2 decimals in python?

How do I round to 2 decimals?

In python, you have floats and decimals that can be rounded. If you care about the accuracy of rounding, use decimal type. If you use floats, you will have issues with accuracy.

All the examples use demical types, except for the original value, which is automatically casted as a float.

To set the context of what we are working with, let's start with an original value.

Original Value