Skip to content

Instantly share code, notes, and snippets.

View SkYNewZ's full-sized avatar
🐳
Working from home

Quentin Lemaire SkYNewZ

🐳
Working from home
View GitHub Profile
@SkYNewZ
SkYNewZ / main.go
Last active December 5, 2020 03:15
Check that each strings fields in a Struct are non-zero value using reflect and return error contains specific tag value
// validate ensure all required secrets are set up
func (secrets *s) validate(sub ...interface{}) error {
// Reflect it
v := reflect.ValueOf(*secrets)
if len(sub) > 0 {
// Recursive
v = reflect.ValueOf(sub[0])
}
// Iterate over each fields and looks from empty string
@SkYNewZ
SkYNewZ / Caddyfile
Created October 7, 2020 17:13
Example Caddyfile for using as load balancer
{
# Enable Debug mode
debug
# Disable admin API
admin off
}
localhost {
# https://caddyserver.com/docs/caddyfile/directives/push
@SkYNewZ
SkYNewZ / main.py
Last active November 2, 2020 19:57
Python37 Google Cloud Logger with urllib3 handler
"""
Used to write logs on Stackdriver logging using the https://googleapis.dev/python/logging/latest/client.html
Detect if we are in Google Runtime environment and enable this logger or not
Change the default format
Append all urllib3 debug request into these loggers
https://stackoverflow.com/questions/16337511/log-all-requests-from-the-python-requests-module
https://github.com/psf/requests/issues/1297
https://stackoverflow.com/questions/11820338/replace-default-handler-of-python-logger
https://stackoverflow.com/questions/879732/logging-with-filters
@SkYNewZ
SkYNewZ / main.tf
Created September 16, 2020 13:02
Create a custom Pub/Sub subscription with a Cloud Function as Push endpoints with Google authentication
variable "project_id" {
type = string
}
# On va chercher le projet number
data "google_project" "project" {
project_id = var.project_id
}
# On crer le topic qui reçoit les lettres mortes
@SkYNewZ
SkYNewZ / Keybaseproof.md
Created April 17, 2019 21:20
Keybase proof

Keybase proof

I hereby claim:

  • I am skynewz on github.
  • I am skynewz (https://keybase.io/skynewz) on keybase.
  • I have a public key ASC3A0QNIzOr05kNumVLg6NbuzLoN-PMKt7AiR9AJTUANQo

To claim this, I am signing this object:

@SkYNewZ
SkYNewZ / extract.go
Created February 21, 2019 18:30
Simple script written in Golang to extract all variables of a given .tf file
package main
import (
"regexp"
"fmt"
"io/ioutil"
"os"
)
func main() {