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 / opencv-build.sh
Last active August 2, 2022 14:06
OpenCV build with CUDA
#!/usr/bin/env bash
#
# ========================================================================
# Script for compilation and installation of OpenCV with CUDA hardware
# acceleration for a Python environment on an Ubuntu-based machine.
# ========================================================================
# Originally written for OpenCV 4.6.0 and Ubuntu 20.04
#
# The script attempts to automatically infer the CUDA version and location
# (thank you NVIDIA for making this more complicated than necessary!).
@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 / mac_finder.py
Last active June 23, 2022 23:51
MAC address finder
"""Method to find MAC address in text (find_mac_address()) and testing routine."""
from dataclasses import dataclass
from typing import List, Optional, Set
import re
import random
RANDOM_SEED = 42
RND = random.Random(RANDOM_SEED)
@lucaspar
lucaspar / cisco_vpn_autoconnect.sh
Last active September 10, 2022 22:25
Automatically connect to Cisco VPN GUI client
#!/bin/env bash
# Script to automate VPN client start and entering credentials
# "xdotool key" and "xdotool type" commands were not working
# most of times when using the --window option, so the script
# uses the "wmctrl" to switch window focus before typing or
# pressing keys.
# === BEFORE FIRST EXECUTION ===
# Set VPN_USERNAME below;
# Store the VPN password once with secret-tool:
# secret-tool store --label "Cisco VPN credentials" vpn_client "$VPN_USERNAME"
@lucaspar
lucaspar / tmux.sh
Last active July 20, 2022 22:57
Wrapper functions for tmux
# Usage: tm <session-name>
# If the session does not exist, it will be created.
# If the session exists, the terminal will be re-attached.
# If no session name is provided, the latest attached session is then re-attached.
# tmux wrapper to re-attach to a tmux session by name
function tm() {
# if already in a tmux session, do nothing
if [ -n "$TMUX" ]; then
echo "Already in tmux session $TMUX"
@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 / corr_conv.py
Last active October 4, 2019 20:33
[ SCR ] Correlation and Convolution Script
#!/usr/bin/env python
# Implementation of correlation and convolution kernels with no dependencies (e.g. numpy)
# Translated from the mathematical expressions with a focus on readability (not very "pythonic")
# ----------
# print image matrix
def printimg(img, title=''):
@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 / xorg.conf
Last active October 4, 2019 20:33
[ FIX ] Blank screen fix after Nvidia update.
# ::: NVIDIA INSTALL :::
#
# Nvidia driver installation: https://linuxconfig.org/how-to-install-the-nvidia-drivers-on-ubuntu-18-04-bionic-beaver-linux.
# Method of "Manual Install using the Official Nvidia.com driver".
#
# ::: DISPLAY FIX :::
#
# 0. append the following to /usr/share/sddm/scripts/Xsetup:
# ---------
# xrandr --setprovideroutputsource modesetting NVIDIA-0
@lucaspar
lucaspar / phone_as_audio_source.sh
Last active August 10, 2022 23:02
[ FIX ] Sets phone as audio source for laptop speakers through bluetooth 🔉
#######################################################################
## Sets phone as audio source for laptop speakers through bluetooth ##
#######################################################################
# check bluetooth
rfkill list
# if bluetooth blocked, run
rfkill unblock bluetooth