Skip to content

Instantly share code, notes, and snippets.

View clementlecorre's full-sized avatar
🤖
hhuhhh

Clément clementlecorre

🤖
hhuhhh
View GitHub Profile
@lelandbatey
lelandbatey / assign_struct_field_by_tag_name.go
Last active November 8, 2023 15:20
Golang reflection; assign to struct field by tag name
package main
import (
"fmt"
"reflect"
"strings"
)
// The goal: allow assignment to a go struct field based on the name that field
// is tagged with (specifically it's json-tagged name).

Preview

Preview

Description

Displays the number of Bluecars available from an Autolib' station.

Dependencies

# Virtustream + RackHD use cases
Gabi, Rod, and I had a chance to sit down and go over a broad swath of feedback
related to their use of RackHD in deploying sites. To provide some background,
they've deployed 8 preliminary sites with RackHD, about 50 nodes each, with a
target of orchestrating a typical deployment of 200-250 physical compute servers.
Their configuration has a single RackHD instance per site, and her team (of which
you'll see Jamie, John & David on the Slack channel) is focused entirely on bare metal
verification and provisioning and standing up these sites as efficiently as possible.
@kizbitz
kizbitz / dockerhub-v2-api-organization.sh
Last active August 2, 2024 14:58
Get the list of images and tags for a Docker Hub organization account
#!/bin/bash
# Example for the Docker Hub V2 API
# Returns all images and tags associated with a Docker Hub organization account.
# Requires 'jq': https://stedolan.github.io/jq/
# set username, password, and organization
UNAME=""
UPASS=""
ORG=""
@sivel
sivel / inventory2json.py
Last active December 19, 2023 01:54
Ansible inventory to dynamic inventory JSON output, accepts all inventory input formats
import sys
import json
from ansible.parsing.dataloader import DataLoader
try:
from ansible.inventory.manager import InventoryManager
A24 = True
except ImportError:
from ansible.vars import VariableManager
@lalyos
lalyos / generate-compose.sh
Created April 5, 2015 18:59
generate docker-compose.yml by inspecting a running container
docker-yml() {
docker inspect -f $'
{{.Name}}
image: {{.Config.Image}}
entrypoint: {{json .Config.Entrypoint}}
environment: {{range .Config.Env}}
- {{.}}{{end}}
' $1
}
@mattes
mattes / check.go
Last active October 11, 2024 16:22
Check if file or directory exists in Golang
if _, err := os.Stat("/path/to/whatever"); os.IsNotExist(err) {
// path/to/whatever does not exist
}
if _, err := os.Stat("/path/to/whatever"); !os.IsNotExist(err) {
// path/to/whatever exists
}
@hyg
hyg / gist:9c4afcd91fe24316cbf0
Created June 19, 2014 09:36
open browser in golang
func openbrowser(url string) {
var err error
switch runtime.GOOS {
case "linux":
err = exec.Command("xdg-open", url).Start()
case "windows":
err = exec.Command("rundll32", "url.dll,FileProtocolHandler", url).Start()
case "darwin":
err = exec.Command("open", url).Start()
@denji
denji / nginx-tuning.md
Last active November 5, 2024 10:10
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@denji
denji / http-benchmark.md
Last active October 13, 2024 00:43
HTTP(S) Benchmark Tools / Toolkit for testing/debugging HTTP(S) and restAPI (RESTful)