This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| # Convert all mp4 videos in the current directory to animated GIF files. | |
| # https://github.com/ImageOptim/gifski?tab=readme-ov-file#from-ffmpeg-video | |
| for f in *.mp4; do | |
| ffmpeg -i "$f" -f yuv4mpegpipe - | gifski --fps 15 --width 480 -o "${f%.mp4}.gif" - | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #! /usr/bin/env bash | |
| # brew install imagemagick | |
| # brew install jpegoptim | |
| mkdir 2048 | |
| for image in *.jpg; do | |
| convert $image -resize 2048x2048\> ./2048/$image | |
| jpegoptim --strip-all -q --max=80 ./2048/$image | |
| done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env sh | |
| # Rename all file in the current directory according to their file creation date | |
| # For jpegs the file date will be set according to its EXIF data | |
| # e.g. | |
| # "20130628_014218.txt" not renamed | |
| # "test.TXT" => "20130628_002938.txt" | |
| # file extensions will be lower case | |
| jhead -ft -dt -autorot -exonly -n%Y%m%d_%H%M%S *.[Jj][Pp][Gg] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # From https://superuser.com/questions/314239/how-to-join-merge-many-mp3-files | |
| ffmpeg -f concat -safe 0 -i <(for f in ./*.mp3; do echo "file '$PWD/$f'"; done) -c copy "all_tracks.mp3" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env zsh | |
| # Usage: copy_dates.sh source_file dest_file | |
| # Requires: Xcode Command Line Tools (for SetFile) | |
| set -euo pipefail | |
| if (( $# != 2 )); then | |
| echo "Usage: $0 source_file dest_file" >&2 | |
| exit 1 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # gem install icalendar | |
| require 'icalendar' | |
| # Open a file or pass a string to the parser | |
| cal_file = File.open("/path/to/my_large_calendar.ics") | |
| # Parser returns an array of calendars because a single file | |
| # can have multiple calendars. | |
| cals = Icalendar::Calendar.parse(cal_file) | |
| cal = cals.first |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| # frozen_string_literal: true | |
| # Example usage: | |
| # ./check_namespaces.rb | |
| # for dir in */; do (cd "$dir" && ../check_namespaces.rb); done | |
| # ./check_namespaces.rb path/to/test/ | |
| # ls -d *components/**/test/* | xargs ./check_namespaces.rb | |
| require "prism" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # https://gist.github.com/wteuber/c435bafcd79beb91b65e354fc907efe8 | |
| # macOS/zsh | |
| # Apply Ruby's keyword argument and hash value omission in a git repo | |
| # First occurence only | |
| git grep -lP '\b([A-Za-z0-9_]+): \1\b[,\)]' -- '*.rb' | head -1 | xargs -I {} sed -i -E 's/\b([A-Za-z0-9_]+): \1\b([,\)])/\1:\2/g' "{}" | |
| # Apply for "<var>: <var>," and "<var>: <var>)" | |
| git grep -lP '\b([A-Za-z0-9_]+): \1\b[,\)]' -- '*.rb' | xargs -I {} sed -i -E 's/\b([A-Za-z0-9_]+): \1\b([,\)])/\1:\2/g' "{}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Usage: ./generate_random_bitmaps.sh <width> <height> <color> <entropy> | |
| # Example ./generate_random_bitmaps.sh 100 100 red 0.8 | |
| # Default dimensions | |
| WIDTH=${1:-100} | |
| HEIGHT=${2:-100} | |
| PIXELS=$((WIDTH * HEIGHT)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| git ls-files | xargs wc -w 2> /dev/null | ruby -e "puts ARGF.map{_1.scan(/^\s*(\d+)/)[0][0].to_i}.inject(&:+)" |
NewerOlder