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 / jupyter_env.txt
Last active February 22, 2023 17:32
jupyterlab setup and python minimal dependencies
black>=22.3.0
gitdb==4.0.9
itables~=1.1.2
ipython>=8.3.0
ipython-genutils==0.2.0
ipywidgets~=7.7.0
isort~=5.10.1
jupyter-client==7.3.0
jupyter-core==4.10.0
jupyter-server==1.17.0
@josemarcosrf
josemarcosrf / ngrok.yml
Last active July 16, 2023 15:31
ngrok configuration
# File to be found at: ~/.config/ngrok/ngrok.yml
# More info: https://ngrok.com/docs/ngrok-agent/config#config-ngrok
authtoken: <your-auth-token-here>
# To allow for transparent background
console_ui: true
console_ui_color: transparent
@josemarcosrf
josemarcosrf / midv-500-stream.py
Last active October 19, 2021 20:04
Stream data from an s3 like bucket (e.g: DigitalOcean spaces) directly into memory. (midv-500 dataset streaming example)
import json
import os
import tarfile
import numpy as np
import cv2
import matplotlib.pyplot as plt
from collections import defaultdict
@josemarcosrf
josemarcosrf / get-npm-package-version
Last active June 21, 2021 09:30 — forked from DarrenN/get-npm-package-version
Extract version from package.json (NPM) using bash / shell
# Version key/value should be on his own line
cat ./package.json | grep -m 1 version | sed 's/[^0-9.]//g'
echo $PACKAGE_VERSION
@josemarcosrf
josemarcosrf / gdrive_download.sh
Created March 19, 2021 10:11
Download Google Drive file with wget
#!/usr/bin/env bash
set -e
set -o pipefail
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" \
@josemarcosrf
josemarcosrf / g_sheet_functions.gs
Created February 25, 2021 12:26
Google Docs (sheets, docs, etc) helper functions
/**
* Returns the URL of a hyperlinked cell, if it's entered with hyperlink command.
* Supports ranges
* @param {A1} reference Cell reference
* @customfunction
*/
function linkURL(reference) {
var sheet = SpreadsheetApp.getActiveSheet();
var formula = SpreadsheetApp.getActiveRange().getFormula();
var args = formula.match(/=\w+\((.*)\)/i);
@josemarcosrf
josemarcosrf / configure_cuda_with_xorg_in_cpu.md
Created February 20, 2021 21:01 — forked from alexlee-gk/configure_cuda_p70.md
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.

@josemarcosrf
josemarcosrf / clean_disk.sh
Created January 14, 2021 19:28
Script to clean up and free disk space in Linux; Docker, Snap, cache, etc
#!/bin/bash
set -eu
set -o pipefail
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" \
@josemarcosrf
josemarcosrf / vm_setup.sh
Last active March 4, 2024 22:02
Shell script to do the first setup install of utilities and minimum dev tools on a clean Ubuntu (Anaconda, Docker, ...)
#!/usr/bin/env bash
# set -e
# set -o pipefail
say() {
echo "$@" | sed \
-e "s/\(\(@\(red\|magenta\|yellow\|blue\|magenta\|cyan\|white\|reset\|b\|u\)\)\+\)[[]\{2\}\(.*\)[]]\{2\}/\1\4@reset/g" \
-e "s/@red/$(tput setaf 1)/g" \
@josemarcosrf
josemarcosrf / py_context_managers.py
Last active October 13, 2023 16:14
Python helper functions, decorators and context managers
import signal
from contextlib import contextmanager
from time import perf_counter
@contextmanager
def timeout(duration: int):
def timeout_handler(signum, frame):
raise Exception(f"Block timed out after {duration} seconds")