Skip to content

Instantly share code, notes, and snippets.

@sillage
sillage / gist:1336681
Last active April 10, 2024 22:10
Save a file in UTF-8 encoding with Vim
:wq! ++enc=utf-8
@sillage
sillage / flactags.sh
Last active December 23, 2023 18:44
flac tags with metaflac
#!/bin/bash
# file format: ARTIST/ALBUM/01-TITLE.flac
read -p "YEAR? " -n 4 YEAR
ALBUM="${PWD##*/}" # ALBUM=$(basename "${PWD}")
ARTIST=$(echo $(cd .. && echo "${PWD##*/}"))
# delete all
metaflac --preserve-modtime --remove-all-tags *.flac
# artist, album, year and cover
metaflac --preserve-modtime --set-tag=ARTIST="${ARTIST}" --set-tag=ALBUM="${ALBUM}" --set-tag=DATE=${YEAR} --import-picture-from=Folder.jpg *.flac

Creating a two way sync between a Github repository and Subversion

Another git <> svn post?

As many of you know I have been on a quest to get Jetpack core development moved from the WordPress.org Subversion (svn) repository to Github (git). As part of this process I setup an experimental Jetpack repository to see how synchronization works between git and svn. Lets just clear the air right now and say not well, not well at all. This is due to how git and svn each store their respective histories. But! I think I finally have it figure out.

Backfill

I wrote an article a couple months ago entitled Creating a synchronized Github fork of a WordPress.org Subversion plugin repository. This article is great (and still a recommended read) if you are only doing synchronization b

@sillage
sillage / gist:1944623
Created February 29, 2012 21:37
piratebay magnet scrape
use warnings;
use strict;
use Parallel::ForkManager;
use 5.010;
my $pm=new Parallel::ForkManager(50);
use Fcntl qw(:flock SEEK_END);
$pm->run_on_finish(sub{
my (undef, undef, undef, undef, undef, $res_ref) = @_;
@sillage
sillage / pypi.sh
Last active November 2, 2019 21:40
Upgrade all PyPI packages
#!/bin/sh
for p in $(pip list --outdated | awk -F ' ' 'NR>2{print $1}')
do pip install --upgrade $p
done
@sillage
sillage / mp3tags.sh
Last active January 11, 2019 20:25
MP3 tags with eyeD3
#!/bin/bash
# file format: ARTIST/ALBUM/01-TITLE.mp3
read -p "YEAR? " -n 4 YEAR
ALBUM="${PWD##*/}" # ALBUM=$(basename "${PWD}")
ARTIST=$(echo $(cd .. && echo "${PWD##*/}"))
# help: eyeD3 -h
# delete all
eyeD3 --preserve-file-times --remove-all *.mp3
# artist, album, year and cover
eyeD3 --preserve-file-times --v2 --artist "${ARTIST}" --album "${ALBUM}" --release-year ${YEAR} --add-image Folder.jpg:FRONT_COVER *.mp3
@sillage
sillage / youtube-dl.sh
Created January 8, 2019 22:26
youtube-dl
# audio
youtube-dl -x --audio-format mp3 --audio-quality 0 --embed-thumbnail --add-metadata -o "%(title)s-%(id)s.%(ext)s" -- URL
# video
youtube-dl -f best -o "%(title)s-%(id)s.%(ext)s" -- URL
#!/bin/bash
# source: https://superuser.com/a/764524
# Managed formats:
# <xmp:CreateDate>2017-07-19T08:53:29Z</xmp:CreateDate>
# <xmp:CreateDate>2017-10-16T12:07:43+02:00</xmp:CreateDate>
# xmp:CreateDate="2013-09-03T17:37:08+02:00"
for f in *.pdf
do
@sillage
sillage / exifdate.sh
Last active April 7, 2017 20:57
Rename pictures with Exif DateTimeOriginal prefix
#! /bin/sh
# Rename pictures with Exif DateTimeOriginal prefix
# format: YYYYmmdd_HHMMSS_:basename:
exiv2 -r '%Y%m%d_%H%M%S_:basename:' rename $(ls *.JPG *.jpg 2>/dev/null)
# format (Dropbox like): YYYY-mm-dd HH.MM.SS_:basename:
# exiv2 -r '%Y-%m-%d %H.%M.%S_:basename:' rename $(ls *.JPG *.jpg 2>/dev/null)
@sillage
sillage / terminaltips.sh
Last active January 15, 2017 15:34
Terminal Tips
#!/bin/sh
# Terminal Tips: Make hidden Dock icons transparent
defaults write com.apple.dock showhidden -bool true && killall Dock
# Terminal Tips: Enable "path view" in Finder
defaults write com.apple.finder _FXShowPosixPathInTitle -bool YES && killall Finder
# How to prevent .DS_Store file creation over network connections
defaults write com.apple.desktopservices DSDontWriteNetworkStores true
# Allow text selection in the Quick Look window
defaults write com.apple.finder QLEnableTextSelection -bool true && killall Finder