Skip to content

Instantly share code, notes, and snippets.

@frntn
frntn / genpass.sh
Created August 2, 2017 22:57
GenPass function to your bashrc
# add this to your .bashrc
function genpass {
isint='^[1-9][0-9]*$'
[[ $1 =~ $isint ]] && count=$1 || count=1
[[ $2 =~ $isint ]] && len=$2 || len=10
for i in $(seq 1 $count); do </dev/urandom tr -dc A-Za-z0-9 | head -c$len ; echo ; done
}
@frntn
frntn / fd-setcolor.sh
Last active August 21, 2017 09:31
Colored File Descriptor
#!/bin/bash
# just put this at the beginning of your scripts
trap "{ sleep 1; }" EXIT
red="" ; [ -t 1 ] && [ -t 2 ] && red="$(tput setaf 1)"
rst="" ; [ -t 1 ] && [ -t 2 ] && rst="$(tput sgr0)"
logdir="/tmp"
exec 3> "$logdir/raw.log"
exec 2> >( awk '{print strftime("%Y%m%dT%H:%M:%S%z")" - STDERR - "$0 ; fflush(stdout)}' | tee -a $logdir/${0%.*}.err > >( awk '{print "'$red'"$0"'$rst'" ; fflush(stdout)}' ))
exec 1> >( awk '{print strftime("%Y%m%dT%H:%M:%S%z")" - STDOUT - "$0 ; fflush(stdout)}' | tee -a $logdir/${0%.*}.out)
@frntn
frntn / gpg-key-validity.sh
Created June 21, 2017 01:59
GnuPG web of trust : automate multiple scenarii to help the understanding of https://www.gnupg.org/gph/en/manual/x334.html
#!/bin/bash
# Author: Matthieu Fronton <[email protected]>
# Profile: github.com/frntn
# Description: GnuPG web of trust : automate multiple scenarii to help the understanding of https://www.gnupg.org/gph/en/manual/x334.html
WAIT=4
if [ -t 1 ]; then
cya="$(tput setaf 6)"
#!/bin/bash
cd "$(dirname "$0")"
GIT_KEYS="gitkey_*" # my git keys are always loaded but agent forwarding is limited specific Hosts
SSH_KEYS="" # my ssh keys are never loaded
SSH_AGENT_PID=1 # `kill -0 1` will always fail for non-root
SSH_AGENT_ENV=".agent_env"
[ -f "${SSH_AGENT_ENV}" ] && source "${SSH_AGENT_ENV}" > /dev/null # load latest known agent pid
kill -0 $SSH_AGENT_PID 2>/dev/null && return # and stop here if still running (do not 'exit' because file may be source'd)
@frntn
frntn / pullpush.sh
Last active August 1, 2017 12:18
Git: pull all + push all
# Pull all
git clone [email protected]:frntn/sample.git
cd sample/
git checkout --detach
git fetch origin '+refs/heads/*:refs/heads/*'
# Push all
git remote add alternate [email protected]:frntn/sample.git
git push -u alternate --all
git push -u alternate --tags
@frntn
frntn / keybase.md
Created September 14, 2016 12:30
Verifying myself: I am frntn on Keybase.io

Keybase proof

I hereby claim:

  • I am frntn on github.
  • I am frntn (https://keybase.io/frntn) on keybase.
  • I have a public key whose fingerprint is CE46 FE45 3E9E 935C A68C 81D0 D385 289F A809 234F

To claim this, I am signing this object:

@frntn
frntn / gist:5495e63fac1d83c1eb11
Created February 20, 2016 11:23
Undocumented Docker Environment Variables
# clone repo and extract all DOCKER_* environment variables used in the code
git clone https://github.com/docker/docker.git
cd docker
grep -rn "os.Getenv" . | sed -r 's/([^:]*:[0-9]*:).*os.Getenv\(([^\)]*)\).*/\2/' | grep DOCKER_ | sort -u
# remove all documented DOCKER_* envrionemnt variables (https://docs.docker.com/engine/reference/commandline/cli/#environment-variables)
"DOCKER_BINARY"
"DOCKER_CONTAINER_NAT"
@frntn
frntn / gist:f25726df962fc29c6dde
Last active July 14, 2024 15:15
azure-cli cheatsheet
azure
account
list [options] #List the imported subscriptions
show [options] [subscriptionNameOrId] #Show details about a subscription
set [options] <subscriptionNameOrId> #Set the current subscription
clear [options] #Remove a subscription or environment, or clear all of the stored account and environment info
import [options] <file> #Import a publishsettings file or certificate for your account
download [options] #Launch a browser to download your publishsettings file
env... #Commands to manage your account environment
<!-- http POST data with cli -->
{
"HostConfig": {
"RestartPolicy": {
"MaximumRetryCount": 0,
"Name": ""
},
"NetworkMode": "bridge",
"SecurityOpt": null,
"VolumesFrom": null,
@frntn
frntn / gcloud_commands
Last active February 27, 2024 11:10
all gcloud commands
gcloud auth
gcloud auth activate-refresh-token
gcloud auth activate-service-account
gcloud auth git-helper
gcloud auth list
gcloud auth login
gcloud auth print-access-token
gcloud auth print-refresh-token
gcloud auth revoke
gcloud components