Skip to content

Instantly share code, notes, and snippets.

View sylr's full-sized avatar

Sylvain Rabot sylr

View GitHub Profile
@sylr
sylr / fgflatten.py
Last active June 22, 2021 14:08
Fortigate config address group flattening script
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# This file is based on github.com/maaaaz/fgpoliciestocsv
#
# Copyright (C) 2021, Sylvain Rabot <sylvain at abstraction .fr>
# Copyright (C) 2014, 2020, Thomas Debize <tdebize at mail.com>
# All rights reserved.
#
# This script is a free software: you can redistribute it and/or modify
from __future__ import absolute_import, division, print_function
import argparse
import http.server
import json
import sys
import urllib.parse
import webbrowser
from urllib.parse import urlparse
import requests
### Keybase proof
I hereby claim:
* I am sylr on github.
* I am sylr (https://keybase.io/sylr) on keybase.
* I have a public key ASAiPbnJcHTFwPhDIKPs78SeFplZqxnISRvCAcPsuOtzxgo
To claim this, I am signing this object:
@sylr
sylr / deployment.yaml
Created November 4, 2020 16:10
kustomize-controller
apiVersion: apps/v1
kind: Deployment
metadata:
annotations:
deployment.kubernetes.io/revision: "8"
creationTimestamp: "2020-11-02T14:42:53Z"
generation: 8
labels:
app.kubernetes.io/instance: flux
app.kubernetes.io/version: latest
@sylr
sylr / internet_check.sh
Last active September 23, 2020 09:24 — forked from SuperQ/internet_check.sh
A script to check internet connectivity with the node_exporter textfile
#!/usr/bin/env sh
URLS[0]="https://www.google.com"
URLS[1]="http://169.254.169.254/metadata/instance?api-version=2020-06-01" # azure internal endpoint
HEADERS[O]=""
HEADERS[1]="-H 'Metadata: true'"
OUTPUT=${OUTPUT:-/tmp/curl.prom}
SLEEP=${SLEEP:-10}
@sylr
sylr / inheap.go
Created March 5, 2020 17:01
inheap
package main
import (
_ "unsafe"
"fmt"
)
var slice = []byte("AAA")
func main() {
@sylr
sylr / wg.go
Created February 11, 2020 09:49
wg.go
package main
// Original code found at: https://play.golang.org/p/kWmjEuXn0ab
import (
"fmt"
"sync"
"time"
)
@sylr
sylr / test.log
Last active November 20, 2019 08:18
Alertmanager make test
✘ s.rabot@wmbpro-srabot  ~/go/src/github.com/prometheus/alertmanager   master  make 09:12:40
>> checking code style
>> checking license header
>> running golangci-lint
GO111MODULE=on go list -e -compiled -test=true -export=false -deps=true -find=false -tags= -- ./... > /dev/null
go: finding github.com/prometheus/client_golang v1.2.1
GO111MODULE=on /Users/s.rabot/go/bin/golangci-lint run ./...
>> running check for unused/missing packages in go.mod
GO111MODULE=on go mod tidy
>> running check for unused packages in vendor/
@sylr
sylr / hpa.yaml
Last active November 8, 2019 08:53
k8s-prometheus-adapter deployment avg cpu usage / deployment limit ratio rule (based on cAdvisor and kube-state-metrics)
kind: HorizontalPodAutoscaler
apiVersion: autoscaling/v2beta1
metadata:
name: {{ HPA }}
spec:
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: {{ DEPLOYMENT }}
minReplicas: 2
@sylr
sylr / clone.go
Created May 27, 2019 11:57
Clone object in golang
package main
import (
"fmt"
)
type Wheel struct {
// Diameter Wheel diameter in centimeters
Diameter int64
}