Skip to content

Instantly share code, notes, and snippets.

View euberdeveloper's full-sized avatar

Eugenio Berretta euberdeveloper

View GitHub Profile
@euberdeveloper
euberdeveloper / sweating-nvm.sh
Last active April 9, 2021 22:08
If you have nvm installed but it does not work with sudo, this is the solution you are seeking. (sweating-nvm because in Italian sudo means "I sweat"). Just run it and it should work. (Note that it sould be copy-pasted directly to the shell)
NVM_VERSION=$(nvm version)
sudo ln -s "$NVM_DIR/versions/node/$NVM_VERSION/bin/node" "/usr/bin/node"
sudo ln -s "$NVM_DIR/versions/node/$NVM_VERSION/bin/npm" "/usr/bin/npm"
sudo ln -s "$NVM_DIR/versions/node/$NVM_VERSION/bin/npx" "/usr/bin/npx"
@euberdeveloper
euberdeveloper / unsweating-docker-1.sh
Last active June 9, 2021 08:28
If you have docker installed but it does not work without sudo, this is the solution you are seeking. (unsweating-docker because in Italian sudo means "I sweat"). Just run it and it should work.
# Execute this code
sudo groupadd docker
sudo gpasswd -a $USER docker
# Close your terminal and then execute unsweating-docker-2.sh
@euberdeveloper
euberdeveloper / pyenv-fixes.bash
Last active November 14, 2021 22:17
This should fix some errors with pyenv
# Fixes error when installing pylint on pipenv with pyenv
sudo apt-get install libffi-dev
# Fixes error on python cli, when pressing arrow up
sudo apt-get install libreadline-dev
# Fixes _lzma strange error
sudo apt install liblzma-dev
# Fixes error when using jupyter notebooks
sudo apt install libsqlite3-dev
# Uninstall your python version
pyenv uninstall 3.9.5
# This line of code makes Pipenv install the virtual environment in the same folder of the Pipfile (under .venv)
export PIPENV_VENV_IN_PROJECT="enabled"
# Install phpenv
curl -L https://raw.githubusercontent.com/phpenv/phpenv-installer/master/bin/phpenv-installer \
| bash
# --- COPY WHAT IS DISPLAYED ON THE CONSOLE IN THE END OF YOUR BASHRC ---
# Install missing libraries used to install various php versions by phpenv
apt install libxml2-dev
apt install libjpeg-dev
apt install libonig-dev
@euberdeveloper
euberdeveloper / convert_webm_to_mp4.sh
Last active February 5, 2022 23:42
A scraper with Puppeteer that saves all the videos of the course "Program optimization" at TUM Informatik Msc. 2021/2022
#!/bin/bash
for filepath in ./*.webm; do
filename=$(basename -- "$filepath")
filename="${filename%.*}"
ffmpeg -i ${filename}.webm ${filename}.mp4
done
@euberdeveloper
euberdeveloper / fix-tab-copilot-md.json
Created February 5, 2022 16:55
On VSCode, the markdown extension is in conflict with the TAB of github copilot, so it does suggestions but you can not accept it. This fixes it.
// Add this to the shortcuts of VSCode
[
{
"key": "tab",
"command": "markdown.extension.onTabKey",
"when": "editorTextFocus && !inlineSuggestionVisible && !editorReadonly && !editorTabMovesFocus && !hasOtherSuggestions && !hasSnippetCompletions && !inSnippetMode && !suggestWidgetVisible && editorLangId == 'markdown'"
},
{
"key": "tab",
"command": "-markdown.extension.onTabKey",
#!/bin/bash
git fetch --tags -f
@euberdeveloper
euberdeveloper / make-chinese-character-rank-by-sound-without-tones.js
Created July 17, 2022 15:48
A script that shows the ranking of the chinese characters, based on their sound without considering the tones
const https = require('https');
const fs = require('fs');
function analyzeInputData(charactersText) {
const ranking = charactersText.split('\n').map(line => line.trim()).filter(line => !!line).map(line => JSON.parse(line)).map(line => {
if (line.frequency_rank === '8220') {
line.pinyin = 'y\u01cen';
}
else if (line.frequency_rank === '9019') {
line.pinyin = 'ni\u00e1n';
port=80
sudo iptables -I INPUT 6 -m state --state NEW -p tcp --dport $port -j ACCEPT
sudo netfilter-persistent save