Skip to content

Instantly share code, notes, and snippets.

View CristianCantoro's full-sized avatar
🎯
Focusing

Cristian Consonni CristianCantoro

🎯
Focusing
View GitHub Profile
@CristianCantoro
CristianCantoro / sudo-password-stdin.txt
Created July 19, 2024 10:18
Passing the password to sudo on stdin
# if you prepend spaces your password is not saved in ~/.bash_history
# (assuming you have the default configuration)
# Options:
# * `--stdin/-S` read the password from stdin
# * `-v` is used to refresh the credentials cache without issuing a command
# * `-p ''` mutes the prompt
# using echo
sudo -p '' --stdin -v < <(echo '<password>')
@CristianCantoro
CristianCantoro / looks_like_scanned.sh
Created May 28, 2024 16:08
Script to make a PDF look like it was scanned
#!/usr/bin/env bash
# shellcheck disable=SC2128
SOURCED=false && [ "$0" = "$BASH_SOURCE" ] || SOURCED=true
if ! $SOURCED; then
set -euo pipefail
IFS=$'\n\t'
fi
#################### help
@CristianCantoro
CristianCantoro / munroe_geohashing.py
Created March 17, 2023 04:26
Automated Munroe geohashing
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# == Author ==
# Cristian Consonni
# This script was generated making extensive use of ChatGPT v3.5
#
# == License ==
#
# MIT License
@CristianCantoro
CristianCantoro / git-setup.md
Last active March 19, 2023 19:49
Setup git user on a server as on GitHub

Setup a git user on a server to behave as on GitHub

Let's assume that you want to put your repositories in the directory /data/repositories.

Setup

  1. Create a gituser group
# addgroup --system gituser
+ /home
+ /var
- /dev
- /home/*/.cache/*
- /home/*/.local/share/Trash
- /home/*/.mozilla/firefox/*/Cache
- /mnt
- /proc
- /run
- /selinux
@CristianCantoro
CristianCantoro / rsync.excludes
Last active September 11, 2022 02:24
rsync full-system backup excludes file
*.!Sync
*.bak
*.bts
*.Cache
*.crdownload
*.lock
*.part
*.shm
*.swp
*.sync
@CristianCantoro
CristianCantoro / README.md
Created June 20, 2021 02:05
Catboost: from RawFormulaVal to probabilities for Mullticlassification

How to calculte class probabilities from RawFormulaVal in Multiclassification problems with Catboost

you get probabilities for the i-th test case by doing:

np.exp(preds_raw[i])/sum(np.exp(preds_raw[i])

Example:

ipdb> preds_raw = model.predict(test_pool, prediction_type='RawFormulaVal')
@CristianCantoro
CristianCantoro / generate.sh
Last active March 5, 2021 23:11
Compression efficiency comparison
#!/usr/bin/env bash
SOURCED=false && [ "$0" = "$BASH_SOURCE" ] || SOURCED=true
if ! $SOURCED; then
set -euo pipefail
IFS=$'\n\t'
fi
tmpdir=$(realpath "$(mktemp -d -t test.tmp.XXXXXXXXXX)")
@CristianCantoro
CristianCantoro / # perl - 2020-04-20_19-14-27.txt
Created April 20, 2020 18:11
perl on Ubuntu 16.04.6 LTS - Homebrew build logs
Homebrew build logs for perl on Ubuntu 16.04.6 LTS
Build date: 2020-04-20 19:14:27
@CristianCantoro
CristianCantoro / # perl - 2020-04-11_22-16-42.txt
Created April 17, 2020 17:16
perl on Ubuntu 16.04.6 LTS - Homebrew build logs
Homebrew build logs for perl on Ubuntu 16.04.6 LTS
Build date: 2020-04-11 22:16:42