Skip to content

Instantly share code, notes, and snippets.

View Neutrollized's full-sized avatar
🎯
Focusing

Glen Yu Neutrollized

🎯
Focusing
View GitHub Profile
@Neutrollized
Neutrollized / nginx_ingress_rewrite.yaml
Created June 3, 2022 15:38
Medium: NGINX Ingress or GKE Ingress
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress-rewrite
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
nginx.ingress.kubernetes.io/rewrite-target: /$2
spec:
@Neutrollized
Neutrollized / nginx_ingress_no_rewrite.yaml
Last active June 3, 2022 15:36
Medium: NGINX Ingress or GKE Ingress
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nginx-ingress-no-rewrite
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/ssl-redirect: "false"
spec:
defaultBackend:
@Neutrollized
Neutrollized / web.yaml
Created June 3, 2022 15:34
Medium: NGINX Ingress or GKE Ingress
---
apiVersion: v1
kind: Service
metadata:
labels:
app: web
name: web
annotations:
cloud.google.com/neg: '{"ingress": true}'
spec:
@Neutrollized
Neutrollized / search_reserved_ip.py
Created June 3, 2022 15:31
Medium: Managing your GCP inventory with Cloud Asset API
def search_reserved_ips():
# create client
client = asset_v1.AssetServiceClient()
# init request
request = asset_v1.SearchAllResourcesRequest(
scope="projects/myproject-123",
asset_types=[
"compute.googleapis.com/Address",
],
@Neutrollized
Neutrollized / main.py
Created June 3, 2022 15:27
Medium: Managing your GCP inventory with Cloud Asset API (export_assets)
import base64
from google.cloud import asset_v1
def export_assets(event, context):
# create client
client = asset_v1.AssetServiceClient()
print("""This Function was triggered by messageId {} published at {} to {}
""".format(context.event_id, context.timestamp, context.resource["name"]))
# bq partition spec
@Neutrollized
Neutrollized / main.py
Created June 3, 2022 15:23
Medium: DIY Google Cloud Storage replication using Cloud Functions (delete_from_gcs)
import string
from google.cloud import storage
def delete_from_gcs(event, context):
print('Event ID: {}'.format(context.event_id))
print('Event type: {}'.format(context.event_type))
print('File: {}'.format(event['name']))
storage_client = storage.Client()
source_bucket = storage_client.bucket(event['bucket'])
@Neutrollized
Neutrollized / main.py
Last active June 3, 2022 15:21
Medium: DIY Google Cloud Storage replication using Cloud Functions (copy_to_gcs)
import string
from google.cloud import storage
def copy_to_gcs(event, context):
print('Event ID: {}'.format(context.event_id))
print('Event type: {}'.format(context.event_type))
print('File: {}'.format(event['name']))
storage_client = storage.Client()
source_bucket = storage_client.bucket(event['bucket'])
@Neutrollized
Neutrollized / namespaces.yaml
Last active June 4, 2022 00:42
Medium: Getting started with GKE Gateway Controller
---
apiVersion: v1
kind: Namespace
metadata:
name: infra-ns
labels:
shared-gateway-access: "true"
---
apiVersion: v1
kind: Namespace
@Neutrollized
Neutrollized / rbenv_macos_bigsur.md
Last active August 18, 2023 12:35
Installing Ruby with rbenv on MacOS Big Sur

Errors/Problems with Install

In attempting to install Ruby with rbenv, I ran into the following build failures:

BUILD FAILED (macOS 11.2.3 using ruby-build 20210423)

Inspect or clean up the working tree at /var/folders/58/16lnyx815c183j6wzcbl_thc0000gn/T/ruby-build.20210426232453.81982.XfAg0C
Results logged to /var/folders/58/16lnyx815c183j6wzcbl_thc0000gn/T/ruby-build.20210426232453.81982.log

Last 10 log lines:
 ^
@Neutrollized
Neutrollized / markdown_to_pdf.md
Created April 15, 2021 21:58
Convert markdown to PDF

Install pandoc

brew install pandoc

How-To

The following will convert markdown file to a PDF file:

pandoc myfile.md -s -o myfile.pdf