Skip to content

Instantly share code, notes, and snippets.

View fvigotti's full-sized avatar
😊
Working hard

Francesco fvigotti

😊
Working hard
View GitHub Profile
@fvigotti
fvigotti / rofi_builder.md
Created March 26, 2021 15:44
rofi builder dockerized

hi to everyone, If you hade issues finding a compiled binary of rofi, and your package manager isn't updated.. you may need this useful

this create a temp docker container and build rofi, the built binary than is taken from the container and replaced in the host.. let me know if you have a better solution

docker run --rm -ti --name rofibuild ubuntu:20.04 bash 

apt update && apt upgrade &&  
apt install  -y rofi-dev qalc libtool  \
git \
pkg-config \
@fvigotti
fvigotti / FluxDeadLockInvestigation.kt
Created July 2, 2019 07:31
investigating deadlock in kotlin
package net.FluxDeadLockInvestigation
import kotlinx.coroutines.*
import kotlinx.coroutines.channels.Channel
import kotlinx.coroutines.reactor.asFlux
import org.junit.jupiter.api.Test
import reactor.core.scheduler.Schedulers
class FluxDeadLockInvestigation(){
@fvigotti
fvigotti / Postfix: sender-dependent SASL authentication.md
Created October 26, 2018 14:21 — forked from zmwangx/Postfix: sender-dependent SASL authentication.md
Postfix: sender-dependent SASL authentication — relay to multiple SMTP hosts, or relay to the same host but authenticate as different users (e.g., two Gmail accounts)

This is a sequel to "Postfix: relay to authenticated SMTP".

I would like to send mail from two different Gmail accounts using Postfix. Here is the relevant section in the Postfix documentation: Configuring Sender-Dependent SASL authentication.

As a concrete example, here's how to set up two Gmail accounts (only relevant sections of the config files are listed below):

/etc/postfix/main.cf:
    # sender-dependent sasl authentication
    smtp_sender_dependent_authentication = yes

sender_dependent_relayhost_maps = hash:/etc/postfix/sender_relay

@fvigotti
fvigotti / purge_prom_pushgateway.sh
Created October 1, 2018 13:56
this is a sample script that clean old metrics from pushgateway, not very clean but working anyway, used as sample in a issue
trap 'echo "got sigterm" ; exit 0' SIGTERM
EXPIRATION_SECONDS=${EXPIRATION_SECONDS:-900}
PGW_URL=${PGW_URL:-http://pushgateway}
function convert_to_standardnotation(){
# convert number from scientific notation to standar d( ie '1.5383780136826127e+09' )
printf '%.0f' $1
}
@fvigotti
fvigotti / docker.service
Created September 13, 2018 07:21
graceful docker/kubernetes shutdown sample
[Unit]
Description=Docker Application Container Engine
Documentation=http://docs.docker.com
After=network.target docker.socket
Wants=docker.socket
[Service]
Type=notify
Environment=GOTRACEBACK=crash
i="0"
while [ $i -lt 1000000000 ]
do
echo line $i
i=$[$i+1]
done
i="0"
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: hostn-hndp
name: hostn-hndp
spec:
replicas: 1
selector:
matchLabels:
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
labels:
app: hostn-port
name: hostn-port
spec:
replicas: 1
selector:
matchLabels:
@fvigotti
fvigotti / fabric.plugin.zsh
Created September 13, 2016 10:07 — forked from AdrienLemaire/fabric.plugin.zsh
zsh-completion for Fabric in Oh-my-zsh
#compdef fab
_targets() {
_describe -t commands "fabric targets" target_list
}
output_levels=(
'status: Status messages, i.e. noting when Fabric is done running, if the user used a keyboard interrupt, or when servers are disconnected from. These messages are almost always relevant and rarely verbose.'
'aborts: Abort messages. Like status messages, these should really only be turned off when using Fabric as a library, and possibly not even then. Note that even if this output group is turned off, aborts will still occur – there just won’t be any output about why Fabric aborted!'
'warnings: Warning messages. These are often turned off when one expects a given operation to fail, such as when using grep to test existence of text in a file. If paired with setting env.warn_only to True, this can result in fully silent warnings when remote programs fail. As with aborts, this setting does not control actual warning behavior, only whether warning messages are printed or hidden.'
#!/usr/bin/env bash
args=("$@")
ELEMENTS=${#args[@]}
for (( i=0;i<$ELEMENTS;i++)); do
echo '['$i']'${args[${i}]}'[/'$i']'
done