Skip to content

Instantly share code, notes, and snippets.

View fcoclavero's full-sized avatar

Francisco Clavero fcoclavero

View GitHub Profile
@fcoclavero
fcoclavero / decorators.py
Last active August 4, 2023 20:11
Django Cheatsheet
class SuppressExceptionsDecorator:
"""Decorator for temporarily suppressing specified exceptions.
Exception suppression is limited to the function execution.
Example:
```python
import warnings
@SuppressErrorsDecorator(MyException)
def foo():
@fcoclavero
fcoclavero / get_value.sh
Last active December 20, 2022 02:59
Envfiles
# Get value on variable in .env file
cat .env | grep $VAR_NAME | sed 's/.*=//'
# Get current speed
defaults read -g com.apple.mouse.scaling
# Set speed (maximum of 7.0)
defaults write -g com.apple.mouse.scaling 5.0
@fcoclavero
fcoclavero / cheatsheet.sh
Created November 4, 2022 16:09
Poetry cheatsheet
# Clear cache
poetry cache clear _default_cache --all
poetry cache clear pypi --all
@fcoclavero
fcoclavero / mamba_cheatsheet.sh
Created October 24, 2022 19:31
Mamba cheatsheet
# Install Poetry 1.2
mamba install -c "conda-forge/label/cleo_dev" cleo
mamba install -c "conda-forge/label/poetry_dev" poetry=1.2
@fcoclavero
fcoclavero / conda_cheatsheet.sh
Last active December 20, 2022 02:47
Conda cheatsheet
# Backup environment to file
conda env export --channel $ENV_NAME --file "$FILE_PATH.yaml"
# Clone conda env
conda create --name myclone --clone root
@fcoclavero
fcoclavero / create_iam_role.yaml
Last active September 22, 2023 14:44
GCP cheatsheet
# Run the following command:
# `gcloud iam roles create my_project.deployer --project $PROJECT_ID --file role.yaml`
#
# Use `my.custom.role` (dot-separated format) as role ID for consistency.
# See: https://cloud.google.com/iam/docs/reference/rest/v1/projects.roles
# role.yaml
title: My Custom Role
@fcoclavero
fcoclavero / inspections.txt
Created December 10, 2021 19:57 — forked from pylover/inspections.txt
PyCharm inspections
# Extracted using: $ unzip -p lib/pycharm.jar com/jetbrains/python/PyBundle.properties | grep -B1 INSP.NAME | grep '^#' | sed 's|Inspection||g' | sed -e 's|#\s\{,1\}|# noinspection |'
# noinspection PyPep8
# noinspection PyPep8Naming
# noinspection PyTypeChecker
# noinspection PyAbstractClass
# noinspection PyArgumentEqualDefault
# noinspection PyArgumentList
# noinspection PyAssignmentToLoopOrWithParameter
# noinspection PyAttributeOutsideInit
@fcoclavero
fcoclavero / instructions.md
Created December 28, 2020 21:55
Fix Razer device not detected on macOS Big Sur 11.1

@Jandalf I recently had to reset my System Integrity Protection settings (csrutil clear) and once again ran into this issue, where my Razer device was not recognized.

I have upgraded to macOS Big Sur 11.1, and I can confirm that the solutions by @avaddon and @rdabban, which had worked for me on 11.0, no longer work.

Manually loading the kernel extension (the kextload command) will display the error code 27 "Extension with identifiers com.razer.common.razerhid not approved to load. Please approve using System Preferences.", but no pop-up or "Allow" option would appear anywhere on the System Preferences.

Adding the Razer TeamID with the /usr/sbin/spctl kext-consent add R2H967U7J8 command showed me a pop-up, but with no "Allow" option, and no option to allow the kernel extension would appear in the System Preferences, so no good.

I finally managed to make it work by temporarily disabling System Integrity Protection (SIP), as follows:

@fcoclavero
fcoclavero / screens.sh
Last active December 20, 2022 02:22
Linux cheatsheet
# Open a screen session, create a new window, and start a shell in that window:
screen
# Start named session:
screen -S session_name
# Reattach screen:
screen -r $SCREEN_ID
# List running screens: