Skip to content

Instantly share code, notes, and snippets.

View andrewhodel's full-sized avatar

Andrew Hodel andrewhodel

View GitHub Profile
@andrewhodel
andrewhodel / ffmpeg_audio_video_files_sync.sh
Last active May 23, 2023 15:31
ffmpeg synchonize audio and video
# trim video file to a certain range of frames
ffmpeg -i render0000-28914.mp4 -vf select="between(n\,0\,61),setpts=PTS-STARTPTS" one.mp4
# display number of frames in a video file
ffmpeg -i one.mp4 -f null /dev/null
# add audio to video file at the start and extend the audio to the end of the video with silence
ffmpeg -i one.mp4 -i electricity-zap.mp3 -filter_complex "[1:0]apad" -shortest test.mp4
# add audio to video file and leave audio length as is, -stream_loop will loop the audio faster than the video with this file
@andrewhodel
andrewhodel / rc.local-amazon-linux-2023
Created August 2, 2023 00:35
rc.local on amazon linux 2023
sudo systemctl status rc-local
sudo systemctl enable rc-local
sudo systemctl start rc-local
sudo systemctl status rc-local
# it doesn't start because /etc/rc.d/rc.local does not exist
sudo ln -s /etc/rc.local /etc/rc.d/rc.local
@andrewhodel
andrewhodel / go-pprof.md
Last active January 13, 2025 21:17
Go profiling with pprof

Importing net/http/pprof adds HTTP endpoints to an existing HTTP or HTTPS server to serve profile files that can be viewed or charted with a command line tool.

import pprof into the go program

import _ "net/http/pprof"

If your application is not already running an http or https server, add "net/http" to the program imports and the following code to your main function:

go http.ListenAndServe(":8550", nil)
@andrewhodel
andrewhodel / golang_slice_delete.md
Last active April 15, 2025 15:08
Golang: delete from slice performance by CPU instruction count

This proves slices.Delete is the fastest method on x86-64 by CPU instruction count.

All methods usually report 0 nanoseconds when running these tests using time, that is why it tests by using CPU instruction count.

delete without order preserved
	 22 CPU instructions (speed)
delete using append with order preserved
	 1508 CPU instructions (speed)
delete using slices.Delete with order preserved