Skip to content

Instantly share code, notes, and snippets.

View josuebrunel's full-sized avatar

Josue Kouka josuebrunel

View GitHub Profile
@andreagrandi
andreagrandi / pelican2hugo.py
Last active May 16, 2025 15:02
Python script to migrate posts from Pelican to Hugo
# Migration script from Pelican to Hugo
import os, re, shutil
from pathlib import Path
INPUT_FOLDER = "content"
OUTPUT_FOLDER = "content-hugo"
# Custom sort key function
def sort_key(path):
# Extract the base filename without the extension
@preslavrachev
preslavrachev / do.go
Last active August 4, 2022 13:15
Do is an experiment in mimicking the Result type (known from languages like Rust and Haskell). The idea is to minimize the amount of error checking and let the developer focus on the happy path, without undermining the power of Go's errors. The code below requires Go 1.18+, as it makes use of generic type parameters.
package do
type Void struct{}
type Result[T any] interface {
Unwrap() (T, error)
}
type defaultResult[T any] struct {
val T
@Integralist
Integralist / handle unknown json data structure.go
Last active May 29, 2025 16:18
Go: handle unknown json data structure #go #json #serialization
package main
import (
"encoding/json"
"fmt"
"log"
)
func main() {
var (
@philippegirard
philippegirard / main.py
Created April 18, 2020 20:18
fastapi logging middleware
import logging
from fastapi import FastAPI
from uicheckapp.services import EchoService
logging.config.fileConfig('logging.conf', disable_existing_loggers=False)
logger = logging.getLogger(__name__)
app = FastAPI()
@Saafke
Saafke / code.py
Created March 31, 2020 10:03
Python code for upscaling an image via OpenCV
import cv2
from cv2 import dnn_superres
# Create an SR object
sr = dnn_superres.DnnSuperResImpl_create()
# Read image
image = cv2.imread('./input.png')
# Read the desired model
@StevenACoffman
StevenACoffman / goGetPrivate.md
Last active June 13, 2025 18:31 — forked from dmitshur/gist:6927554
How to `go get` private repos using SSH key auth instead of password auth.

Set GOPRIVATE to match your github organization

I keep fixing this up, but if it fails for you, check if these are better maintained https://tip.golang.org/cmd/go/#hdr-Configuration_for_downloading_non_public_code and https://golang.org/ref/mod#private-modules.

Cloning the repo using one of the below techniques should work correctly but you may still be getting an unrecognized import error.

As it stands for Go v1.13, I found in the doc that we should use the GOPRIVATE variable like so:

GOPRIVATE=github.com/ORGANISATION_OR_USER_NAME go get -u -f github.com/ORGANISATION_OR_USER_NAME/REPO_NAME

The 'go env -w' command (see 'go help env') can be used to set these variables for future go command invocations.

@jtbonhomme
jtbonhomme / hasMany.go
Created May 22, 2018 11:11
Gorm example of foreign key definition for a hasMany relation
package main
import (
"fmt"
"github.com/jinzhu/gorm"
_ "github.com/jinzhu/gorm/dialects/postgres"
)
// Customer ...
type Customer struct {
@booleangate
booleangate / a-salesforce-oauth-2.0-jwt-bearer-token-flow-walk-through.md
Last active May 8, 2025 00:39
Salesforce OAuth 2.0 JWT Bearer Token Flow walk-through

Salesforce OAuth 2.0 JWT Bearer Token Flow Walk-Through

This document will walk you through how to create or configure a Salesforce application for use with JWT authentication. These configuration steps and the example code works as of Salesforce API version 42.0.

Prerequisites

Create an RSA x509 private key/certification pair

@steven2358
steven2358 / ffmpeg.md
Last active July 21, 2025 19:10
FFmpeg cheat sheet
import cgi
def parse_form_data(formdata):
fp = cgi.StringIO(formdata)
env = cgi.os.environ
env['REQUEST_METHOD'] = 'POST'
data = cgi.FieldStorage(fp, environ=env)
return data