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 / .golangci.yaml
Created November 14, 2023 21:53
.golangci.yaml golden configuration
# Inspired from https://gist.github.com/maratori/47a4d00457a92aa426dbd48a18776322
run:
timeout: 5m
modules-download-mode: readonly
linters:
enable-all: true
disable:
- bodyclose
@SkYNewZ
SkYNewZ / main.go
Created November 9, 2023 21:19
Get YouTube channel ID from channel URL in Go
package main
import (
"fmt"
"io/ioutil"
"net/http"
"os"
"regexp"
)
@SkYNewZ
SkYNewZ / main.go
Created November 8, 2022 12:49
Go constant backoff retry with max iterations count
// You can edit this code!
// Click here and start typing.
package main
import (
"errors"
"fmt"
"time"
"github.com/cenkalti/backoff"
@SkYNewZ
SkYNewZ / main_test.go
Created January 25, 2022 15:29
Golang append using make/cap vs slice literal
❯ go test -bench=. -v ./main_test.go
goos: darwin
goarch: amd64
cpu: Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
BenchmarkAppendMake
BenchmarkAppendMake-8 17486152 67.63 ns/op 0 B/op 0 allocs/op
BenchmarkAppendMakeCap
BenchmarkAppendMakeCap-8 2189421 540.8 ns/op 2040 B/op 8 allocs/op
PASS
ok command-line-arguments 3.124s
FROM node:16 as builder
ENV NODE_ENV production
WORKDIR /usr/src/app
# Deps
COPY package.json yarn.lock ./
RUN yarn install \
--emoji false \
--no-progress \
@SkYNewZ
SkYNewZ / errs.go
Created May 23, 2021 00:40 — forked from grahamking/errs.go
Collect and handle multiple errors in Go
package util
import (
"errors"
"strings"
)
// Errs is an error that collects other errors, for when you want to do
// several things and then report all of them.
type Errs struct {
@SkYNewZ
SkYNewZ / scratch.go
Created April 23, 2021 10:24
Context cancellation example in Go
package main
import (
"context"
"fmt"
"math/rand"
"os"
"time"
)
@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 / 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 / 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() {