Skip to content

Instantly share code, notes, and snippets.

View mvidaldp's full-sized avatar
🎯
Focusing

Marc Vidal De Palol mvidaldp

🎯
Focusing
  • Cologne, Germany
View GitHub Profile
@mvidaldp
mvidaldp / .bashrc
Created June 7, 2020 21:32
Gentoo's default BASHRC file (very nice color schemes)
# /etc/bash/bashrc
#
# This file is sourced by all *interactive* bash shells on startup,
# including some apparently interactive shells such as scp and rcp
# that can't tolerate any output. So make sure this doesn't display
# anything or bad things will happen !
# Test for an interactive shell. There is no need to set anything
# past this point for scp and rcp, and it's important to refrain from
@mvidaldp
mvidaldp / PERSISTENT_ARCH_USB.md
Created June 7, 2020 22:18
Reminder: persistent Arch USB Linux kernel and Intel ucode upgrades

Extracted from: https://sourceforge.net/projects/arch-linux-usb-os/files/ArchUsbOs/

*** Arch USB OS uses save partition to save changes you make and programs you install When it comes to kernel+initramfs and intel-ucode upgrade this is problematic since these - are used to boot the OS but do so while residing on the USB drive itself, outside the squashed file system. So when kernel or intel-ucode is upgraded in order to be able to reboot you will have to - copy-paste files between "save" and "boot" partition.

Boot into another Linux installation or Linux Boot CD or USB and mount 'ARCH USB OS'- USB drive

@mvidaldp
mvidaldp / wordpress_on_nginx.sh
Last active July 1, 2020 12:40
How to correctly set permission to run Wordpress on NGINX
# by default NGINX runs the master process as root and worker processes as user http
sudo chown http:http /var/www/yoursitefolder -R
# set only the necessary permissions (0755 for folders and 0644 for files)
sudo find /var/www/yoursitefolder -type d -exec chmod 0755 {} \; # folders
sudo find /var/www/yoursitefolder -type f -exec chmod 0644 {} \; # files
@mvidaldp
mvidaldp / ByteArray2Int.java
Last active October 19, 2020 09:23
How to decode signed and unsigned 12 and 24-bit encoded integers from a byte array in Java
// For unsigned integers, all byte array elements are decoded as unsigned using (value & 0xff) before the left shift (<<)
private static int byteArrayToUInt(byte[] input) {
if (input.length == 3) { // 24-bit encoded
// always decode them starting from right to left (2, 1, 0 indices in this example)
return (input[0] & 0xFF) << 16 | (input[1] & 0xFF) << 8 | (input[2] & 0xFF); // lowercase F(f) also works
} else if (input.length == 2) { // 12-bit encoded
return (input[0] & 0xFF) << 8 | (input[1] & 0xFF);
}
}
@mvidaldp
mvidaldp / HowTo_GitHub_Fork_even_with_master.md
Created August 19, 2020 14:43
Set GitHub fork even with the master branch. Aka gitHub says "This branch is X commits ahead, Y commits behind" after pull requests merged.

Assuming your are inside your fork folder and the pull requests you did were accepted and so merged into the master branch of the repo. Run once at first:

git remote add upstream https://github.com/upstream/repo.git

Then whenever you want to make your fork even (sync changes), run:

git pull --rebase upstream master
git push --force-with-lease origin master
@mvidaldp
mvidaldp / rename.sh
Created November 2, 2020 02:51
Rename all extensions of the files from a folder
for f in *.old; do
mv -- "$f" "${f%.old}.new"
done
# source: https://unix.stackexchange.com/a/19656
@mvidaldp
mvidaldp / Detach.txt
Last active November 19, 2020 18:26
How to detach Android apps from PlayStore to prevent autoupdate.
- Given that your phone is rooted with Magisk (https://github.com/topjohnwu/Magisk), place this "Detach.txt" file on "/storage/emulated/0/" and include your app names after line 45 (run `adb shell 'pm list packages -f'` to get their names). Finally, just install Detach module using Magisk (https://github.com/Magisk-Modules-Repo/Detach) and reboot.
- Detach Market Apps Configuration -
- Remove comment (#) to detach an App.
#Contacts
#Gmail
#Google App
#Google Plus
#Hangouts
#Phone
@mvidaldp
mvidaldp / custom_pbar_tqdm.gif
Last active November 19, 2020 19:47
How to make a customized progress bar in Python using TQDM (https://github.com/tqdm/tqdm)
custom_pbar_tqdm.gif
@mvidaldp
mvidaldp / howto_matlab_on_jupyter.md
Created November 23, 2020 13:00
How to use Matlab on Jupyter Notebooks
  1. Assuming you created a virtual environment called matlab, otherwise:
python -m venv matlab
  1. Activate the venv:
source matlab/bin/activate
  1. Assuming you have Matlab installed in your OS:
@mvidaldp
mvidaldp / remove_RSA_key_pass.sh
Last active December 4, 2020 01:54
Remove the pass phrase (password) of an RSA key
# assuming you know the key you want to remove
openssl rsa -in key_with_pass.pem -out key_without_pass.pem
# source: https://stackoverflow.com/a/18394172 - https://www.madboa.com/geek/openssl/#key-removepass