Skip to content

Instantly share code, notes, and snippets.

View lucaspar's full-sized avatar

Lucas Parzianello lucaspar

  • University of Notre Dame
View GitHub Profile
@lucaspar
lucaspar / nvenc-install.sh
Last active April 25, 2024 07:01
Installation script of CUDA-accelerated `ffmpeg` with NVIDIA Encoder
#!/bin/bash
# =========================================================================
# Source: https://gist.github.com/lucaspar/27f5e108b80524b315be10b2a9049817
# =========================================================================
# This script will compile and install a static FFmpeg build with
# support for NVENC in Ubuntu. Developed in Ubuntu 23.10,
# with NVIDIA Drivers v535.129.03 and CUDA v12.2 with a GPU
# with CUDA capability 8.6 (RTX 3080) (see ccap below).
# It assumes NVIDA drivers are installed and that you have a
# CUDA-compatible GPU. You can check installed drivers with:
@lucaspar
lucaspar / userChrome.css
Last active March 8, 2024 00:09
Stylesheets for collapsible vertical tabs for Firefox. Tabs expand horizontally when hovered, similar to Edge's.
/*
How to use this CSS:
0. Install the Sidebery extension: https://addons.mozilla.org/en-US/firefox/addon/sidebery/.
1. In Sidebery settings:
a. Set the title preface must as "[S] " (without quotes).
This is used by CSS rules below to identify when Sidebery is active.
b. Set 'Tabs tree structure' to false -- this stylesheet doesn't adapt to
multiple tab levels, but feel free to tweak it!
c. Copy and paste the "SIDEBERY STYLES" section below in
@lucaspar
lucaspar / IRRF-imposto.js
Last active January 22, 2024 16:04
Cálculo de IR em JavaScript com teste unitário.
/* Fonte: https://gist.github.com/lucaspar/2c20754b37920217678cebb64170cb7a */
/**
* Calcula o imposto de renda sobre o valor de rendimentos tributáveis,
* conforme tabela progressiva do ano tributário de 2023, seguindo a
* incidência mensal do imposto sobre a renda de pessoas físicas (IRPF).
*
* @params {Number} rendimentos Renda a ser tributada, em R$.
* @returns {Number} imposto a pagar sobre `rendimentos`, em R$.
**/
@lucaspar
lucaspar / ub-origin-filters.txt
Last active December 20, 2023 08:20
Denser YouTube's subscriptions view, with smaller thumbnails
! Add these lines to the "my filters" section of ublock origin
www.youtube.com##ytd-rich-section-renderer.ytd-rich-grid-renderer.style-scope:nth-of-type(2)
youtube.com##ytd-rich-grid-renderer:style(--ytd-rich-grid-items-per-row: 12 !important;)
youtube.com##ytd-rich-grid-row, #contents.ytd-rich-grid-row:style(display:contents !important;)
@lucaspar
lucaspar / Dockerfile
Last active December 20, 2023 08:10
Minimal installation of Poetry in Docker
# use python3 alpine image
FROM python:3.12-alpine
# install curl
RUN apk add --no-cache curl
# install poetry
RUN curl -sSL https://install.python-poetry.org | python3 -
@lucaspar
lucaspar / slack-notify
Created October 6, 2023 14:44
Slack notification script
#!/bin/env bash
# Slack Notifications
SLACK_WEBHOOK_URL_DEFAULT="https://hooks.slack.com/services/GET/A/LINK"
SLACK_WEBHOOK_URL="$SLACK_WEBHOOK_URL_DEFAULT"
SLACK_PREFIX="${SLACK_PREFIX:=\`$(hostname)\`}"
# notify about error on slack channel if errors happened
function _slack_notify() {
local ERROR_MESSAGE="$SLACK_PREFIX | $1"
@lucaspar
lucaspar / heimdall-style.css
Created July 20, 2023 15:18
Heimdall Style
/* Paste these lines in Settings > Advanced > Custom CSS */
/* ================ */
/* generic elements */
body {
background-color: rgb(16, 16, 16);
color: rgb(198, 198, 198);
/* font-family: monospace; */
line-height: 1.8;
}
@lucaspar
lucaspar / waste_my_ram.py
Created July 14, 2023 20:17
Progressively allocates all memory in a system
"""You probably don't want to run this.
Source: https://stackoverflow.com/a/66109163/2848528
"""
import logging
import secrets
from typing import Optional
from humanfriendly import format_size
@lucaspar
lucaspar / Debugging.md
Created June 24, 2023 21:39
Debugging in containers

Debugging in containers

Tired of "command not found" - these lines will install commonly used tools to debug networking, read logs, and other things.

Start a shell as root inside the container

CONTAINER_KEYWORD="spark"
CONTAINER_NAME=$(docker ps | grep -i "${CONTAINER_KEYWORD}" | head -n 1 | awk '{print $NF}')
echo "CONTAINER_NAME: ${CONTAINER_NAME}"
@lucaspar
lucaspar / pyarrow_conversions.py
Created June 14, 2023 20:03
Benchmark | PyArrow conversions
"""Benchmark the conversion of pyarrow arrays to polars, numpy, and lists."""
import time
from typing import Callable
import numpy as np
import pandas as pd
import polars as pl
import psutil
import pyarrow as pa