Skip to content

Instantly share code, notes, and snippets.

View rafrodriguez's full-sized avatar

Rafael Rodríguez rafrodriguez

View GitHub Profile
fdisk -l
usb-devices
lspci -nv
lsusb
lsusb -t
@rafrodriguez
rafrodriguez / pdf2img2pdf
Last active February 14, 2021 05:49
Convert a pdf into jpg images using ghostscript and back to pdf
# Convert a pdf to set of images and back to pdf
# Read about ghostscript resolution in its manpage
# You need to type Enter after gs command to exit ghostscript's prompt
tmpdir='tmpimages'; mkdir $tmpdir; gs -dNOPAUSE -sDEVICE=jpeg -r200 -sOutputFile=$tmpdir/page%06d.jpg input.pdf; convert $tmpdir/*.jpg output.pdf
@rafrodriguez
rafrodriguez / temps.sh
Created December 13, 2019 07:26
Show temperatures of sensors and nvidia-smi
alias temps='date "+%Y-%m-%dT%H:%M:%S"; sensors | grep C | tr -s " " | cut -d " " -f 3 | tr "\n" " "; echo "" ; nvidia-smi | grep -e Default'
@rafrodriguez
rafrodriguez / pem_to_pub
Created February 17, 2019 04:59
COnvert a pem certificate file to a public key
ssh-keygen -f private.pem -y > public.pub
@rafrodriguez
rafrodriguez / .bashrc
Created January 27, 2019 05:44
Misc. bash .bashrc functions
function mostrecentelementinadir() {
# Usage example:
# tail the most recent log file of logs in $LOGS_DIR
# tail -f $(mostrecentelementinadir $LOGS_DIR)
ls -1d $1/* --color=never -1t | head -n 1
}
@rafrodriguez
rafrodriguez / emdiff
Last active January 26, 2019 07:09
Use emacs ediff similarly to vimdiff, and use it as diff tool for git difftool
#!/bin/bash
# A similar program to vimdiff, using emacs ediff
#
# Usage examples:
#
# Directly compare two files
# emdiff file1 file2
#
# Use it for git difftool (I recommend aliasing this as "gitemdiff")
alias gitadduntrackedincurrdir='git add $(git ls-files -o --exclude-standard)'
alias gitlistuntrackedincurrdir='git ls-files --others --exclude-standard'
@rafrodriguez
rafrodriguez / tmux.md
Created March 26, 2018 19:11 — forked from andreyvit/tmux.md
tmux cheatsheet

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@rafrodriguez
rafrodriguez / commands
Created December 24, 2017 21:09
Misc. commands
# Check whether nvidia driver is in use
grep nvidia /var/log/Xorg*.log
cat /proc/driver/nvidia/version
@rafrodriguez
rafrodriguez / reduceVideoNoiseWithFfmpeg
Last active December 24, 2017 21:48
Reduce image noise in video with ffmpeg
outputSuffix=_denoised.MTS; for item in *.MTS; do if [ $(find -maxdepth 1 -iname "*$(echo $item | tr -d 'denoisedMTS./')*" | wc -l) -ge 2 ]; then echo "$item was already processed"; else ffmpeg -i $item -vcodec libx264 -crf 20 -preset slow -filter:v hqdn3d -c:a copy -strict experimental -ab 192k -threads 16 ".$(echo $item | tr -d '.MTS')$outputSuffix"; fi; done