Skip to content

Instantly share code, notes, and snippets.

View fedir's full-sized avatar
🌤️
The sun is behind every cloud

Fedir RYKHTIK fedir

🌤️
The sun is behind every cloud
View GitHub Profile
@fedir
fedir / .bashrc
Last active March 10, 2020 13:41
Kubernetes Linux Mint
source <(kubectl completion bash) # active l'auto-complétion pour bash dans le shell courant, le paquet bash-completion devant être installé au préalable
echo "source <(kubectl completion bash)" >> ~/.bashrc # ajoute l'auto-complétion de manière permanente à votre shell bash
alias k=kubectl
complete -F __start_kubectl k
@fedir
fedir / tellmeyoursecrets.js
Last active January 20, 2020 15:52 — forked from rzrbld/tellmeyoursecrets.js
Google Apps Script that lists a lot of info about the files in a particular folder/sub folder structure including viewers, editors, and sharing access type
function listFolders(folder) {
var sheet = SpreadsheetApp.getActiveSheet();
sheet.appendRow(["Folder Name" ,"Name","Sharing Access", "Get Editors", "Get Viewers", "Date", "URL"]);
folderID = "ID"
listFolder(sheet, folderID)
}
function listFolder(sheet, folderID) {
var folder = DriveApp.getFolderById(folderID);
addRootFilesToSheet(sheet, folder)
@fedir
fedir / ResolvingGitConflictsInProduction.md
Created January 7, 2020 12:11
Resolving Git conflicts in production

Checking for possible conflicts

git fetch origin branch
git diff --name-only HEAD..origin/branch
git diff HEAD..origin/branch directory_foo/file_bar.ext

Using git vimdiff

git config merge.tool vimdiff

git config merge.conflictstyle diff3

@fedir
fedir / goUpgrade.sh
Last active December 23, 2019 17:14
Go update script for Linux Mint / Ubuntu / Debian (and some other distributions)
#!/bin/bash
# Golang upgrade script
# (C) 2019, Fedir RYKHTIK
# Usage: define the version constants and use it under the account
# Define target constants
VERSION="1.13.5"
OS="linux"
@fedir
fedir / logAnonymizeIps.sh
Last active December 18, 2019 11:12
SHELL > Replace any IP by G.D.P.R :)
#!/bin/bash
sed -i -e 's/[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}/G.D.P.R/g' some.log
@fedir
fedir / showMailQueue.sh
Created December 16, 2019 14:06
Show Postfix's mail queue content
for emails in `mailq | awk '/^[0-9A-F][0-9A-F]/{print $1}'`; do postcat -q $emails;done
@fedir
fedir / pdf_compress.sh
Last active October 8, 2019 13:07
PDF compression with gs (works well on Linux Mint)
# Compressing to EBook quality (between "screen" and "preprocess")
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf
# Black and white output, with custom resolution
gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/default -dCompressFonts=true -r150 -dNOPAUSE -dQUIET -dBATCH -sColorConversionStrategy=Gray -dProcessColorModel=/DeviceGray -sOutputFile=output.pdf input.pdf
@fedir
fedir / result_check.md
Last active July 22, 2020 20:02
Install WKHTMLTOPDF / WKHTMLTOX on CentOS

Installation verification

Bad

$ wkhtmltopdf https://www.google.fr output.pdf
Loading pages (1/5)
Error: Failed loading page https://www.google.fr (sometimes it will work just to ignore this error with --ignore-load-errors)

Good

@fedir
fedir / dd_dsync_check.sh
Last active March 15, 2022 20:59
Disk performance check with dd dsync (synchronized I/O for data)
#!/bin/bash
# Small files (64KB)
dd if=/dev/zero of=./dsync64KB.img bs=64 count=1000 oflag=dsync 2>&1|tee dsync-test-1-64KB.log
# Medium files (8MB)
dd if=/dev/zero of=./dsync8MB.img bs=8k count=1000 oflag=dsync 2>&1|tee dsync-test-2-8MB.log
# Big files (128MB)
dd if=/dev/zero of=./dsync128MB.img bs=128k count=1000 oflag=dsync 2>&1|tee dsync-test-3-128MB.log
@fedir
fedir / slice_filtering.go
Last active March 13, 2019 16:00
golang > the fastest version of a slice of structs filtering will be a recreation of new slice of structs
// ref. https://pauladamsmith.com/blog/2016/07/go-modify-slice-iteration.html
y := x[:0]
for _, n := range x {
if n.property !=42 {
y = append(y, n)
}
}
// If some further sorting should be done, requires Go 1.8+
// https://stackoverflow.com/a/42872183/634275