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 / 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() {
@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 / 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 / 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 / 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.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 / context-timeout.go
Created December 18, 2020 14:22
Simple Go file to understand context cancellation
package main
import (
"context"
"time"
log "github.com/sirupsen/logrus"
)
func main() {
@SkYNewZ
SkYNewZ / main.go
Created January 6, 2021 15:51
List Terraform Cloud workspaces and related runs matching date
package main
import (
"context"
"fmt"
"sync"
"time"
log "github.com/sirupsen/logrus"
@SkYNewZ
SkYNewZ / main.py
Created March 15, 2021 17:27
How to test a Flask/HTTP Cloud Function in Python ?
from flask import Flask, Request, make_response
def hello_http(request: Request):
"""HTTP Cloud Function.
Args:
request (flask.Request): The request object.
<https://flask.palletsprojects.com/en/1.1.x/api/#incoming-request-data>
Returns:
The response text, or any set of values that can be turned into a
@SkYNewZ
SkYNewZ / scratch.go
Created April 23, 2021 10:24
Context cancellation example in Go
package main
import (
"context"
"fmt"
"math/rand"
"os"
"time"
)