Skip to content

Instantly share code, notes, and snippets.

View Dih5's full-sized avatar

Guillermo Hernández Dih5

  • Universidad de Salamanca
  • Salamanca, Spain
View GitHub Profile
@Dih5
Dih5 / random-wallpaper.sh
Created August 28, 2020 21:45
Set a random wallpaper in MATE
#!/bin/bash
# path to the wallpaper directory
rep="$HOME/wallpapers"
# list of files (assumed images)
images=("${rep}/"*)
# Random position
choice=$((${RANDOM} % ${#images[@]}))
@Dih5
Dih5 / pdf2png.sh
Created September 7, 2019 18:16
Convert all pdfs to png with
#!/bin/bash
for f in *.pdf ; do
convert -verbose -density 300 "${f}" "${f%.*}".png
done
@Dih5
Dih5 / coreCount.sh
Created April 30, 2019 09:02
Count the number of cores the system
#!/bin/sh
cat /proc/cpuinfo | grep -i 'processor' | wc -l
@Dih5
Dih5 / sshproxy.sh
Created April 21, 2019 22:52
Remote ssh server as a SOCKS5 proxy with Chromium
ssh -ND 1080 <user>@<host>
chromium --proxy-server="socks5://localhost:1080"
@Dih5
Dih5 / jupyter-plot-format.py
Created January 8, 2019 10:08
Export matplotlib plots to custom formats in Jupyter
# Export matplotlib plots to custom formats in Jupyter
from matplotlib.pyplot import *
%matplotlib inline
from IPython.display import set_matplotlib_formats
set_matplotlib_formats('png', 'pdf')
@Dih5
Dih5 / kaggle-to-local.sh
Created November 20, 2018 16:57
Download a Kaggle dataset and a kernel, run it locally and export as pdf
#!/usr/bin/env bash
export DATA="username/dataset"
export KERNEL="username/kernel-name"
kaggle datasets download --unzip -p input $DATA
kaggle kernels pull -p kernel $KERNEL
jupyter nbconvert --to notebook --execute --allow-errors --inplace kernel/*.ipynb
jupyter nbconvert kernel/*.ipynb --to pdf
mv kernel/*.pdf .
@Dih5
Dih5 / reformat-date-csv.py
Created November 16, 2018 09:15
Reformat a date in a CSV file
#!/usr/bin/env python3
import pandas as pd
original_format='%Y-%m-%d %H:%M:%S'
target_format='%d-%m-%y %H:%M'
attribute_name='Date'
file_path='ACertainFile.csv'
df=pd.read_csv(file_path)
df[attribute_name]=pd.to_datetime(df[attribute_name], format=original_format).apply(lambda x: x.strftime(target_format))
@Dih5
Dih5 / fix-i3mate-desktop.sh
Created July 2, 2018 11:52
Fix the desktop wallpaper for mate+i3
#!/usr/bin/env bash
# Fix the desktop wallpaper for mate+i3
dconf write /org/mate/desktop/background/show-desktop-icons "false"
dconf write /org/mate/desktop/background/show-desktop-icons "true"
dconf write /org/mate/desktop/background/show-desktop-icons "false"
@Dih5
Dih5 / update-overleaf.sh
Created December 13, 2017 12:52
Update a pdf from an Overleaf project cloning it with git
#!/bin/bash
# Update a pdf from an Overleaf project cloning it with git
# pdflatex + bibtex used for compilation
PROJECTID=12345678my-secret-id
FILENAME=main
pushd .
cd /tmp && git clone https://git.overleaf.com/$PROJECTID && cd $PROJECTID && pdflatex $FILENAME.tex && bibtex $FILENAME && pdflatex $FILENAME.tex && pdflatex $FILENAME.tex
@Dih5
Dih5 / DownloadNDL.sh
Created December 8, 2017 14:08
Download a book from National Diet Library
#!/bin/bash
for i in {1..174} # Change number of pages.
do
# Change URL to that of the book.
wget "http://dl.ndl.go.jp/view/jpegOutput?itemId=info%3Andljp%2Fpid%2F971654&contentNo=$i&outputScale=1" -O $i.jpeg
# They kindly ask for waiting 30s between requests. Don't be an ass and do so.
sleep 30
done