Skip to content

Instantly share code, notes, and snippets.

View gerritjandebruin's full-sized avatar

Gerrit Jan de Bruin gerritjandebruin

View GitHub Profile
@gerritjandebruin
gerritjandebruin / energy-and-gas-provider-comparison.ipynb
Created February 20, 2020 21:39
Energy and gas provider comparison
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gerritjandebruin
gerritjandebruin / powerlaw.ipynb
Last active May 18, 2020 09:54
Powerlaw.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11m36s PowerPoint presentation -> .mp4 and then compressing in FFMPEG:
Size | Vcodec | CRF | Preset | Wall time | User time | Size
1080p | h264 | 23 | normal | 5m | 33m | 87M
1080p | libx265 | 28 | normal | 20m | 33m | 40M
1080p | h264 | 17 | normal | 1m* | 19m | 188M
1080p | libx265 | 23 | normal | 21m | 35m | 47M
1080p | h264 | 18 | normal | 1m* | 18m | 166M
1080p | h264 | 19 | normal | 1m* | 18m | 145M
4k | h264 | 23 | normal | 5m* | 137m | 298M
@gerritjandebruin
gerritjandebruin / timelapse.sh
Last active February 7, 2021 15:08
Make timelapse from photos
ffmpeg -framerate 30 -pattern_type glob -i "timelapse/*.JPG" -pix_fmt yuv420p -c:v libx265 -preset veryfast timelapse.mp4
import joblib
from tqdm.auto import tqdm
class ProgressParallel(joblib.Parallel):
def __init__(self, use_tqdm=True, total=None, desc=None, *args, **kwargs):
self._use_tqdm = use_tqdm
self._total = total
self._desc = desc
super().__init__(*args, **kwargs)
@gerritjandebruin
gerritjandebruin / create_html.py
Created May 12, 2021 12:27
Plot hip and plotly to a webpage
html = hip.Experiment.from_iterable(df.to_dict(orient='records')).to_html()
soup = BeautifulSoup(html, 'html.parser')
tag1 = soup.new_tag('div', attrs={'margin-left': 'auto', 'margin-right': 'auto'})
tag1.append(BeautifulSoup(fig1.to_html(include_plotlyjs='cdn', full_html=False)))
soup.body.insert(0, tag1)
tag2 = soup.new_tag('div', attrs={'margin-left': 'auto', 'margin-right': 'auto'})
tag2.append(BeautifulSoup(fig2.to_html(include_plotlyjs='cdn', full_html=False)))
soup.body.insert(1, tag2)
with open('docs/run3.html', 'w') as file:
file.write(str(soup))
@gerritjandebruin
gerritjandebruin / teexgraph.ipynb
Last active October 28, 2021 10:52
Teexgraph.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@gerritjandebruin
gerritjandebruin / enumitem.tex
Created January 14, 2022 20:40
Usefull to make any iteration you want in Latex.
% Define research questions: https://tex.stackexchange.com/questions/525921/ideas-for-presenting-the-research-question
\usepackage{enumitem}
\newlist{questions}{enumerate}{2}
\setlist[questions,1]{wide=0pt,leftmargin=\parindent,label=RQ\arabic*.,ref=RQ\arabic*}
\setlist[questions,2]{label=(\alph*),ref=\thequestionsi(\alph*)}
% In document
\begin{questions}
\item \label{rq:events} How should event-based links, which may re-occur over time, be dealt with in order to accurately predict future links?
\item \label{rq:availability} To what extent does the availability of temporal information improve the performance of link prediction approaches?
@gerritjandebruin
gerritjandebruin / influx_drop_measurement.sh
Last active January 14, 2022 20:41
Drop measurements in Influxdb
for i in 'lightlevel' 'lumi_lumi' 'multisensor' 'rwl021' 'batterij' 'verbinding' 'herstart' 'notificatie' 'oplader' 'tradfri' 'water' 'wifi_signal' 'relais' 'on_off'
do
influx -host xxx -username homeassistant -password xxx -port 8086 --execute 'show measurements' --database=homeassistant | grep $i | xargs -I{} influx -host xxx -username homeassistant -password xxx -port 8086 --execute 'drop measurement "{}"' --database=homeassistant
done
@gerritjandebruin
gerritjandebruin / send_mail.py
Created January 15, 2022 07:26
Send an e-mail on any DSlab server in LIACS.
import os, smtplib
from os.path import basename
from email.mime.application import MIMEApplication
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
from email.utils import COMMASPACE, formatdate
def send_mail(
send_from="bruingjde@liacs.leidenuniv.nl",
send_to: list = ["gerritjan.debruin@gmail.com"],