Skip to content

Instantly share code, notes, and snippets.

View Daniel-Worrall's full-sized avatar

Daniel Worrall Daniel-Worrall

View GitHub Profile
@j8r
j8r / compile-crystal-arm64.sh
Last active October 13, 2024 08:40
Compile a Crystal program to a statically linked arm64 binary
#!/bin/sh -eu
LOCAL_PROJECT_PATH=${1-$PWD}
BUILD_COMMAND="
shards build --static --release
chown 1000:1000 -R bin
"
INSTALL_CRYSTAL="
echo '@edge http://dl-cdn.alpinelinux.org/alpine/edge/community' >>/etc/apk/repositories
apk add --update --no-cache --force-overwrite \
@fnky
fnky / ANSI.md
Last active November 19, 2024 18:05
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@RX14
RX14 / libraries.ps1
Last active March 9, 2024 17:56
Compile libraries needed for Crystal on Windows
.\vs_buildtools.exe --passive --norestart --wait --add Microsoft.VisualStudio.Workload.VCTools --includeRecommended | Out-Default
$script = @'
$installdir = "$pwd"
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
echo "Downloading cmake"
iwr https://cmake.org/files/v3.11/cmake-3.11.4-win64-x64.zip -OutFile cmake.zip
Expand-Archive cmake.zip -DestinationPath .
@olegantonyan
olegantonyan / audio_volume_normalize.rb
Created May 25, 2016 06:58
Normalize audio volume using ffmpeg and ruby
def normalize_volume(file)
output = `ffmpeg -i '#{file}' -af "volumedetect" -f null /dev/null 2>&1`
raise "Error getting audio volume from #{file} (#{$?})" unless $?.success?
max_volume = output.scan(/max_volume: ([\-\d\.]+) dB/).flatten.first
mean_volume = output.scan(/mean_volume: ([\-\d\.]+) dB/).flatten.first
return if !max_volume || !mean_volume
max_volume = max_volume.to_f
mean_volume = mean_volume.to_f
target_volume = -14.0
adjustment = target_volume - mean_volume