Skip to content

Instantly share code, notes, and snippets.

@basperheim
basperheim / install-python3-windows10.md
Last active August 22, 2021 12:42
Install Python 3.8 and upgrade PIP on Windows

Install and setup Python 3 in Windows 10

Download and install Python using the interactive EXE installer and make sure to include the path. Make sure to check the py launcher and pip checkboxes as well.

Screenshot of the Windows 10 interactive install for Python 3

Once it's finished installing open a new command prompt window and verify Python 3 installed properly with the following command:

py -V
@basperheim
basperheim / youtube-dl-download-age-restricted-vidoes.md
Last active January 19, 2022 12:23
Download age-restricted YouTube videos with youtube-dl

Download age-restricted videos on YouTube

2022 UPDATE: It's better to use the YT-DLP fork of youtube-dl at this point. You can always make an alias for yt-dlp like so: alias youtube-dl='/usr/local/bin/yt-dlp' (make sure to replace /usr/local/bin/ with your actual yt-dlp path).

YouTube has recently blocked age-restricted videos from being downloaded. You can use the youtube-dl's --cookies flag to pass your stored cookie preferences to the command to bypass this.

  • Install a Chrome extension like Get Cookies.txt to get your browser's cookies.
  • Install youtube-dl from source, or use Python 3's PIP package manager to install it.
  • Obtain a copy of your browser cookies stored as a .txt file.
@basperheim
basperheim / linux-unix-terminal-commands.md
Last active November 9, 2023 07:38
Common Linux Commands

UNIX Commands Cheat Sheet

A cheat sheet for Linux commands, and how to install some packages and drivers.

Docker commands

Stop containers:

docker stop $(docker ps -a -q); docker rm $(docker ps -a -q)
@basperheim
basperheim / download-youtube-dl-crop-ffmpeg.md
Last active March 6, 2023 07:35
Download and crop YouTube videos using youtube-dl and FFmpeg

Download a YouTube video with youtube-dl

Basic youtube-dl command is: youtube-dl "https://www.youtube.com/watch?v=VIDEO_ID_HERE".

Make sure to do the following first:

  • Ensure the python3 command is working and actually runs a version of Python 3.x.
  • Make sure that the path to your cookies file is correct.
  • Make sure that you have the latest version of youtube-dl installed (youtube-dl --version).
  • Ensure the absolute file path for the youtube-dl binary or installation (In a UNIX-like terminal use which youtube-dl).
@basperheim
basperheim / is-daylight-savings.js
Created September 14, 2021 14:54
Use JavaScript to check if a date is currently DST
/**
* Daylight saving time then ends on the first Sunday in November,
* when clocks are moved back an hour at 2 a.m. local daylight time
* (so they will then read 1 a.m. local standard time). In 2021,
* DST begins on March 14 and ends on Nov. 7 in the U.S.
*
* Defaults to current date. Options are: `{ year: null, month: null, day: null }`
**/
const isDST = (options = { year: null, month: null, day: null }) => {
const d = new Date();
@basperheim
basperheim / nodejs-create-csv.md
Last active November 21, 2021 19:03
Create a CSV file using NodeJS and fast-csv

Write to a CSV file using NodeJS

Outputs data to a CSV file using NodeJS.

Install the fast-csv package

Install the fast-csv NodeJS package:

npm i fast-csv
@basperheim
basperheim / raspberry-pi-no-wireless-interface-found.md
Last active April 30, 2024 17:02
Fix "No wireless interface found" on a Raspberry Pi

Fix "No wireless interface found" on a Raspberry Pi

Step 1 - Fix the interfaces file

Remove everything but first 'source-directory' line in /etc/network/interfaces.

Using nano:

sudo nano /etc/network/interfaces
@basperheim
basperheim / ffmpeg-create-video-from-image-and-mp3.md
Created February 22, 2022 09:36
Use FFmpeg to create an MP4 video from an image and MP3 audio track

Create a video from an image and MP3 file using FFmpeg

Uses the libx264 codec:

ffmpeg -r 1 -loop 1 -y -i input.jpg -i input.mp3 -c:a copy -r 1 -vcodec libx264 -shortest output.mp4
@basperheim
basperheim / compile-julia-package-compiler.md
Last active February 27, 2022 03:54
Compile Julia Project Using Package Compiler
@basperheim
basperheim / dockerfile-ffmpeg-apple-silicon.md
Last active June 28, 2022 19:58
x86 & Apple Silicon Cross-Compatible Docker Setup for FFmpeg

Multi-Architecture Cross-Compatible Docker Setup for FFmpeg

Here's a Docker setup I used to help speed up FFmpeg in the containers by using different compiled binaries for each respective architecture. If someone knows of a better way to do this, or a cleaner way to do this, please let me know.

I've tested this on Ubuntu and Apple Silicon host machines.

Compile FFmpeg for your Apple Silicon