Skip to content

Instantly share code, notes, and snippets.

View mijorus's full-sized avatar
😎

Lorenzo Paderi mijorus

😎
View GitHub Profile
@mijorus
mijorus / floatStr.js
Created March 16, 2024 12:41
This functions is designed to be used in react inputs to collect float numbers. Given an input string and a decimal separator, it will return a new string with any non-numeric characters removed and only one decimal separator
function floatStr(str, outputDecimalSeparator = ',', possibleSeparators = [',', '.']) {
str = str.replace('.', outputDecimalSeparator);
str = str.replace(',', outputDecimalSeparator);
possibleSeparators.forEach(el => {
str = str.replace(el, outputDecimalSeparator);
});
if (str.startsWith(outputDecimalSeparator)) {
import re
from pprint import pprint
class SambaConfig():
def __init__(self) -> None:
self.data = {}
self.original_raw_data = {}
def get_seciton(self, section: str) -> dict:
@mijorus
mijorus / sleepwatcher.md
Last active March 25, 2024 13:33
Commands for sleepwatcher for turning on and off wifi and bluetooth automatically on macOS

Install sleepwatcher from brew

Create ~/.sleep file

#!/bin/zsh

echo $(blueutil -p) > ~/.bluestatus
bluestatus=$(head -n 1 ~/.bluestatus)
@mijorus
mijorus / skip_yt_ads.macro
Last active August 16, 2023 09:34
Skip Youtube ads Macro for Macrodroid - For all the languages
{
"disabledTimestamp": 0,
"forceEvenIfNotEnabledTimestamp": 0,
"isActionBlock": false,
"isBeingImported": false,
"isClonedInstance": false,
"isExtra": false,
"isFavourite": false,
"lastEditedTimestamp": 1692178071905,
"localVariables": [],
@mijorus
mijorus / flatpak-scripts.sh
Last active February 17, 2023 08:53
Flatpak builder scripts
# Run a flatpak
#! /usr/bin/bash
flatpak kill your.app.name
flatpak-builder build/ your.app.name.json --user --force-clean
flatpak-builder --run build/ your.app.name.json app-name
# Install a Flatpak
#! /usr/bin/bash
flatpak kill your.app.name
@mijorus
mijorus / mega-ftp-toggle.sh
Created December 5, 2022 12:36
Mega FTP toggle
# Toggle the ftp server on and off
test -f /tmp/megaftp-on && (mega-ftp -d --all && rm /tmp/megaftp-on && notify-send 'Mega FTP stopped') || (mega-ftp ./ && touch /tmp/megaftp-on && notify-send 'Mega FTP started'
@mijorus
mijorus / howto-swap-navigation-button-motorola.md
Created August 23, 2022 07:26
How to swap back and multitasking buttons on Motorola Phones, without external apps

For how crazy as it sounds, the setting is there but hidden.

Follow these steps:

  1. Add the settings widget to your home screen
  2. Select the 3 buttons navigation option (the label might be localized)
  3. Launch the shortcut
@mijorus
mijorus / bw-backup.py
Last active August 17, 2022 10:04
Exports your bitwarden passwords as temporary json, encrypts and uploads the file to your MEGA
#!/usr/bin/python3
# both megacmd and bw-cli need to be installed and configured before running this script
# bw-cli from snap needs to be configured in order to write in the /tmp folder
# files will be uploaded in the /bw folder on MEGA
import sys
import os
import subprocess
from getpass import getpass
@mijorus
mijorus / create_dict.py
Created July 8, 2022 13:04
Python create dict from variables names
# Credit: https://stackoverflow.com/questions/39818733/create-dictionary-where-keys-are-variable-names
def create_dict(*args: str):
return dict({i:eval(i) for i in args})
@mijorus
mijorus / ternary.py
Created June 2, 2022 12:09
Python ternary operator function shorthand
def qq(condition, is_true, is_false):
return is_true if condition else is_false