Skip to content

Instantly share code, notes, and snippets.

View thomaspoignant's full-sized avatar

Thomas Poignant thomaspoignant

View GitHub Profile
@thomaspoignant
thomaspoignant / Makefile
Last active April 5, 2024 08:50
My ultimate Makefile for Golang Projects
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
BINARY_NAME=example
VERSION?=0.0.0
SERVICE_PORT?=3000
DOCKER_REGISTRY?= #if set it should finished by /
EXPORT_RESULT?=false # for CI please set EXPORT_RESULT to true
GREEN := $(shell tput -Txterm setaf 2)
@thomaspoignant
thomaspoignant / export_dokuwiki
Last active March 17, 2024 03:06
Dokuwiki, export all pages with one command line. The result is all the wiki pages and files in html
wget \
--recursive \
--no-clobber \
--page-requisites \
--no-check-certificate \
--html-extension \
--convert-links \
--restrict-file-names=windows \
--no-parent \
--domains yourdomain.com \
listen: 1031
pollingInterval: 1000
startWithRetrieverError: false
retriever:
kind: http
url: https://raw.githubusercontent.com/thomaspoignant/go-feature-flag/main/examples/retriever_file/flags.goff.yaml
exporter:
kind: log
enableSwagger: true
@thomaspoignant
thomaspoignant / of-goff-example.py
Created February 21, 2024 17:55
GO Feature Flag + OpenFeature example
import time
from gofeatureflag_python_provider.provider import GoFeatureFlagProvider
from gofeatureflag_python_provider.options import GoFeatureFlagOptions
from openfeature import api
from openfeature.evaluation_context import EvaluationContext
from gofeatureflag_python_provider.provider_status import ProviderStatus
retriever:
kind: github # type of retriever we are using
repositorySlug: thomaspoignant/demo-goff # repository we are retrieving
path: flags.yaml # location of the file in the repository
pollingInterval: 5000 # Time in milliseconds we wait before trying to check for changes
@thomaspoignant
thomaspoignant / ticker.go
Last active July 17, 2023 23:27
GO periodically refreshing Cache implementation
package main
import (
"fmt"
"sync"
"time"
)
var mutex sync.RWMutex
var cache map[string]interface{}
@thomaspoignant
thomaspoignant / pipeline.go
Last active February 7, 2023 15:10
Building a pipeline system in golang
package main
import (
"fmt"
"gopkg.in/yaml.v3"
"io"
"net/http"
)
// PipelineConfig is the representation of a pipeline in the configuration.
basePath: /
definitions:
model.FlagEval:
properties:
value: {}
type: object
model.HealthResponse:
properties:
initialized:
description: Set to true if the HTTP server is started
@thomaspoignant
thomaspoignant / sort_pipeline_example.py
Created November 8, 2021 13:48
An example to sort a list of jobs depending on their depends.
from typing import Dict, List, Optional
import networkx as nx
def main():
stages = {
"Lint": [],
"Test": [],
"Coverage": ["Test"],
"Docs": ["Coverage", "Lint"],
# sort the stages
out_degree_map = {v: d for v, d in g.out_degree() if d > 0}
zero_out_degree = [v for v, d in g.out_degree() if d == 0]
while zero_out_degree:
yield zero_out_degree
new_zero_out_degree = []
for v in zero_out_degree:
for child, _ in g.in_edges(v):
out_degree_map[child] -= 1
if not out_degree_map[child]: