Skip to content

Instantly share code, notes, and snippets.

View mhartkorn's full-sized avatar

Martin Hartkorn mhartkorn

View GitHub Profile
@mhartkorn
mhartkorn / plot_aligned_series.R
Created August 15, 2017 13:18 — forked from tomhopper/plot_aligned_series.R
Align multiple ggplot2 graphs with a common x axis and different y axes, each with different y-axis labels.
#' When plotting multiple data series that share a common x axis but different y axes,
#' we can just plot each graph separately. This suffers from the drawback that the shared axis will typically
#' not align across graphs due to different plot margins.
#' One easy solution is to reshape2::melt() the data and use ggplot2's facet_grid() mapping. However, there is
#' no way to label individual y axes.
#' facet_grid() and facet_wrap() were designed to plot small multiples, where both x- and y-axis ranges are
#' shared acros all plots in the facetting. While the facet_ calls allow us to use different scales with
#' the \code{scales = "free"} argument, they should not be used this way.
#' A more robust approach is to the grid package grid.draw(), rbind() and ggplotGrob() to create a grid of
#' individual plots where the plot axes are properly aligned within the grid.
@mhartkorn
mhartkorn / youtube-dl-1080.sh
Last active November 24, 2020 17:53
Downloads a YouTube video with youtube-dl in 1080p60 (or less if no higher resolution is available) and adds the audio track with ffmpeg. Format prioritization is: Video: 1080p60 VP9, 1080p60 H.264, 720p60 VP9, 720p60 H.264, 1080p30 VP9, 1080p30 H.264, 720p30 VP9, 720p30 H.264. Audio: Opus High, M4A High, M4A Medium
#!/usr/bin/bash
TMP_DIR="/tmp/youtube-dl"
STD_ARGS="--no-part --no-playlist -c"
VIDEO_FORMATS="299/303/302/298/248/137/247/136"
AUDIO_FORMATS="251/141/140"
DIST=$RANDOM
OLD_DIR="$PWD"