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 / 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 / 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 / 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 / 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 / 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 / benchmark.py
Last active August 14, 2022 07:25
Video reading benchmarks | OpenCV and Torchvision
"""Benchmarks for the video reader: OpenCV vs Torchvision.
OpenCV is faster than Torchvision when just reading the frames, but it's slower when
adding the conversions to RGB, tensor, float, and stacking the frames.
Results:
Benchmarking OpenCV
Read 300 frames in 0.84 seconds
Read 300 frames in 0.81 seconds
Read 300 frames in 0.98 seconds
@lucaspar
lucaspar / commands
Last active September 9, 2022 21:04
CRC commands
#!/usr/bin/env bash
# Helper program to list useful CRC commands
function get_pager_cmd() {
if command -v bat &>/dev/null; then
echo "bat -l bash"
else
echo cat
fi
}
@lucaspar
lucaspar / ntail
Last active November 26, 2022 07:11
Bash helper for displaying the last lines of an output continuously without cluttering the entire screen like `tail -f`.
#!/bin/bash
# Display last N lines of input like tail, but cleaning the screen before every update.
# Example: date; for i in $(seq 1 2000); do echo $i; sleep 0.03; done | ntail 10
function ntail {
# default to 10 lines of tail output
NUM_LINES=${1:-10}
# gets the current time in milliseconds
@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 / 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;)