Skip to content

Instantly share code, notes, and snippets.

Avatar

Mathias Perlet mperlet

View GitHub Profile
@mperlet
mperlet / crt_to_pem.sh
Created Jun 9, 2017
Shell function to convert .crt to .pem files. Useage: crt_to_pem <my_cert_without_ext>
View crt_to_pem.sh
crt_to_pem = function() {
openssl x509 -in "$1.crt" -out "$1.pem" -outform PEM
}
@mperlet
mperlet / cpdf.sh
Created Jun 6, 2017
compress pdf file $> cpdf my_large_pdf_file.pdf
View cpdf.sh
function cpdf() {
/usr/bin/gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$1.compress.pdf $1
}
View 120secondsofyes.sh
for i in {0..20}
do
yes > /dev/null &
done; sleep 120; kill -9 $(pidof yes)
@mperlet
mperlet / pmap.py
Created Apr 12, 2017
parallel python map function
View pmap.py
def pmap(func, iter, pool_size=4):
""" Like pythons map() function but parallel """
from multiprocessing.dummy import Pool
return Pool(pool_size).map(func, iter)
@mperlet
mperlet / latex commands
Created Apr 6, 2017
list most used latex commands
View latex commands
find . -name "*.tex" -exec cat {} \; | sed "s# #\n#g" | sed "s#\t##g" | sort | grep '^\\' | grep -v '\\end' | uniq -c | sort -nr | head -n100
@mperlet
mperlet / check_iban.py
Created Apr 5, 2017
Python IBAN Checker
View check_iban.py
# Based on http://codereview.stackexchange.com/questions/135366/python-iban-validation
import string
def is_iban(unchecked_iban):
LETTERS = {ord(d): str(i) for i, d in enumerate(string.digits + string.ascii_uppercase)}
def _number_iban(iban):
@mperlet
mperlet / deep_photo_styletransfer_install_example.sh
Created Mar 28, 2017
deep-photo-styletransfer vagrant setup history
View deep_photo_styletransfer_install_example.sh
sudo apt-get update
sudo apt-get install octave git libmatio2 libprotobuf-dev protobuf-compiler nvidia-cuda-toolkit octave-image
git clone https://github.com/luanfujun/deep-photo-styletransfer.git
cd deep-photo-styletransfer/
bash models/download_models.sh
cd ..
git clone https://github.com/torch/distro.git ~/torch --recursive
cd ~/torch; bash install-deps;
./install.sh
@mperlet
mperlet / cpdf.sh
Created Mar 28, 2017
Shell function to compress pdf file usage: cpdf my_big_document.pdf
View cpdf.sh
function cpdf() {
/usr/bin/gs -sDEVICE=pdfwrite -dCompatibilityLevel=1.4 -dPDFSETTINGS=/ebook -dNOPAUSE -dQUIET -dBATCH -sOutputFile=$1.compress.pdf $1
}
@mperlet
mperlet / python_port_open.sh
Created Mar 24, 2017
python port check one line bash
View python_port_open.sh
python -c "import socket;print(True) if 0 == socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(('127.0.0.1',8000)) else False"
@mperlet
mperlet / python_port_open.sh
Created Mar 24, 2017
python port check one line bash
View python_port_open.sh
python -c "import socket;print(True) if 0 == socket.socket(socket.AF_INET, socket.SOCK_STREAM).connect_ex(('127.0.0.1',8000)) else False"
You can’t perform that action at this time.