Skip to content

Instantly share code, notes, and snippets.

View josemarcosrf's full-sized avatar
🏔️
Working from a mountain top

Jose Marcos RF josemarcosrf

🏔️
Working from a mountain top
View GitHub Profile
@josemarcosrf
josemarcosrf / clean_atlas_serverless.sh
Last active October 26, 2023 22:43
Mongo useful command examples; aggregations, dumps, restore, etc
projects=$(atlas projects list | jq -cr '.results[] | {id, name} | select(.name!="test-gpu-261023")')
for row in $projects; do
projectId=$(echo $row | jq -r '.id')
projectName=$(echo $row | jq -r '.name')
echo "Deleting serverless instance: $projectName (ID: $projectId)"
atlas serverless delete $projectName --projectId $projectId
done
for row in $projects; do
@josemarcosrf
josemarcosrf / calibre_library.py
Last active March 15, 2023 16:29
Export Calibre library to find each book's ISBN with Google Book API and export to JSON or CSV file
import click
import json
import requests
import sys
import time
import pandas as pd
from tqdm.auto import tqdm
from rich.progress import track
from rich.console import Console
@josemarcosrf
josemarcosrf / ffmpeg_commands.sh
Created October 10, 2020 10:13
Useful FFMPEG commands
# Encode audo to acc - keep video stream as it is
ffmpeg -i <inut-video>.mp4 -c:v copy -codec:a aac <output-video>.mp4
@josemarcosrf
josemarcosrf / init_dvc.sh
Created August 31, 2020 12:05
Script to initialize and configure DVC (Data Version Control) in a git repository with DigitalOcean Spaces
#!/usr/bin/env bash
say() {
echo "$@" | sed \
-e "s/\(\(@\(red\|green\|yellow\|blue\|magenta\|cyan\|white\|reset\|b\|u\)\)\+\)[[]\{2\}\(.*\)[]]\{2\}/\1\4@reset/g" \
-e "s/@red/$(tput setaf 1)/g" \
-e "s/@green/$(tput setaf 2)/g" \
-e "s/@yellow/$(tput setaf 3)/g" \
-e "s/@blue/$(tput setaf 4)/g" \
-e "s/@magenta/$(tput setaf 5)/g" \
@josemarcosrf
josemarcosrf / auto-toggle-theme.sh
Last active December 24, 2024 12:56
Bash script to toggle / change Gnome and Shell themes and Terminal profiles between dark and light modes
#!/bin/bash
# Cron doesn't have access to env.vars as your user has,
# so we need to export these:
export TERM=xterm-256color
# Check current value with: 'echo $DBUS_SESSION_BUS_ADDRESS' and paste here
# see: https://stackoverflow.com/questions/53628122/git-libsecret-throws-cannot-autolaunch-d-bus-without-x11-display
export DBUS_SESSION_BUS_ADDRESS=unix:path=/run/user/1000/bus
@josemarcosrf
josemarcosrf / decrypt_dbeaver.py
Created June 26, 2020 19:58 — forked from felipou/decrypt_dbeaver.py
DBeaver password decryption script - for newer versions of DBeaver
# https://stackoverflow.com/questions/39928401/recover-db-password-stored-in-my-dbeaver-connection
# requires pycrypto lib (pip install pycrypto)
import sys
import base64
import os
import json
from Crypto.Cipher import AES
@josemarcosrf
josemarcosrf / .tmux.conf
Last active March 24, 2025 23:17
Tmux configuration
# increase history limit to 90K lines
set-option -g history-limit 90000
# Enable mouse mode
set -g mouse on
# remap keys for copy-mode
# bind -t vi-copy y copy-pipe "xclip -sel clip -i"
setw -g mode-keys vi
@josemarcosrf
josemarcosrf / jupyter_kernels.md
Created June 7, 2020 15:09
Jupyter Kernel with virtual env or conda envs

For jupyter notebooks to identify your virtual env kernels:

  1. Activate your env and install ipykernel:
pip install --user ipykernel
  1. Add your virtual environment to Jupyter:
python -m ipykernel install --user --name=myenv
@josemarcosrf
josemarcosrf / install_postman.sh
Created May 30, 2020 15:37
Install postman (not the snap version)
# Download postman (instead of the snap from the Ubuntu Software Store)
wget https://dl.pstmn.io/download/latest/linux64 -O postman.tar.gz
sudo tar -xzf postman.tar.gz -C /opt
rm postman.tar.gz
sudo ln -s /opt/Postman/Postman /usr/bin/postman
# Create a desktop entry
cat > ~/.local/share/applications/postman.desktop <<EOL
[Desktop Entry]
Encoding=UTF-8
@josemarcosrf
josemarcosrf / python-deps.md
Created May 22, 2020 16:55
Utilities to analyse python dependencies

Draw a graph of dependencies

pydeps: Python module dependency visualization

# Draw a graph for <package> with max depth of 3 and cluster expernal deps. Produces an .svg file
pydeps <my-package> 
  --noshow \
  --max-bacon 3 \
 --cluster \