Skip to content

Instantly share code, notes, and snippets.

View YinlinHu's full-sized avatar

Yinlin Hu YinlinHu

  • CVLab, EPFL
  • Lausanne, Switzerland
View GitHub Profile
@YinlinHu
YinlinHu / install-opencv-cuda.sh
Created May 7, 2022 14:16 — forked from pvilas/install-opencv-cuda.sh
Installing OpenCV CUDA and python3 (Tested on AWS p2.xlarge and Deep Learning Ubuntu AMI 22_Aug_2017)
echo "First, you must manually donwload CUDA8 from https://developer.nvidia.com/cuda-downloads"
echo "Ideas taken from https://github.com/BVLC/caffe/wiki/OpenCV-3.2-Installation-Guide-on-Ubuntu-16.04 and http://www.pyimagesearch.com/2016/10/24/ubuntu-16-04-how-to-install-opencv/"
echo "Installing Nvidia drivers"
# Start clean
sudo apt purge nvidia-*
# Add the PPA
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt update
sudo apt-get install nvidia-367
@YinlinHu
YinlinHu / netplan2NM.sh
Created December 6, 2021 14:34 — forked from dbkinghorn/netplan2NM.sh
Change Ubuntu 20.04 server netplan to use NetworkManager instead of networkd
#!/usr/bin/env bash
# netplan2NM.sh
# Ubuntu server 20.04 Change from netplan to NetworkManager for all interfaces
echo 'Changing netplan to NetowrkManager on all interfaces'
# backup existing yaml file
cd /etc/netplan
cp 01-netcfg.yaml 01-netcfg.yaml.BAK
@YinlinHu
YinlinHu / install_opencv41_ubuntu.sh
Last active November 20, 2020 18:15 — forked from kylehounslow/install_opencv41_ubuntu.sh
Script to Install OpenCV 4.1 + contrib modules on Ubuntu 16.04 (for C++ development)
OPENCV_VERSION=4.1.0
apt-get update
apt-get install -y build-essential
apt-get install -y cmake
apt-get install -y wget
apt-get install -y git
apt-get install -y unzip
apt-get install -y yasm
apt-get install -y pkg-config
@YinlinHu
YinlinHu / dumppdfcomments.py
Created June 10, 2020 15:09 — forked from HamedMP/dumppdfcomments.py
Python Script to extract highlighted text from PDFs. Uses python-poppler-qt4. Updated [1] to Python 3 [1] https://stackoverflow.com/questions/21050551/extracting-text-from-higlighted-text-using-poppler-qt4-python-poppler-qt4
import popplerqt4
import sys
import PyQt4
def main():
doc = popplerqt4.Poppler.Document.load(sys.argv[1])
total_annotations = 0
for i in range(doc.numPages()):
@YinlinHu
YinlinHu / compress-pdf-with-gs.md
Created May 30, 2020 19:53 — forked from vibegui/compress-pdf-with-gs.md
Compress PDF files with ghostscript

This can reduce files to ~15% of their size (2.3M to 345K, in one case) with no obvious degradation of quality.

ghostscript -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/printer -dNOPAUSE -dQUIET -dBATCH -sOutputFile=output.pdf input.pdf

Other options for PDFSETTINGS:

  • /screen selects low-resolution output similar to the Acrobat Distiller "Screen Optimized" setting.
  • /ebook selects medium-resolution output similar to the Acrobat Distiller "eBook" setting.
  • /printer selects output similar to the Acrobat Distiller "Print Optimized" setting.
  • /prepress selects output similar to Acrobat Distiller "Prepress Optimized" setting.