Skip to content

Instantly share code, notes, and snippets.

@wilensky
wilensky / 2mp3.sh
Created November 1, 2026 20:19
Makes CBR 44.1 kHz stereo MP3s and writes older-style ID3 tags for broad player compatibility. -n prevents overwriting files. Inputs without an audio stream or in an unsupported format will be skipped with an FFmpeg error.
mkdir -p mp3
for f in *; do
[[ -f "$f" ]] || continue
ffmpeg -n -i "$f" -map 0:a:0 -vn -c:a libmp3lame -b:a 192k \
-ar 44100 -ac 2 -id3v2_version 3 -write_id3v1 1 \
"mp3/${f%.*}.mp3"
done
@wilensky
wilensky / git-reset-author.sh
Created December 23, 2024 12:47
Reset git author for last 3 commits
git rebase --onto HEAD~3 --exec "git commit --amend --reset-author --no-edit" HEAD~3
@wilensky
wilensky / tag.sh
Last active November 9, 2023 15:04
Script recreates an existing Git tag by removing it and creating on the same commit. Useful for checking idempotent triggers or dropping large amount of tags.
#!/usr/bin/env bash
# tag.sh -t my-awesome-tag@1.2.3 -dcyv
#
# -d Deletes tags
# -c Creates tag on the same commit
# -y Non-interactive mode (always YES)
# -v Slightly increased verbosity
TAG=''
@wilensky
wilensky / output_jsonify.js
Created December 24, 2020 11:28
NodeJS raw process output JSONifying (processes line-by-line)
// Usage: ~$ some-process | node output_jsonify.js
const pump = require('pump');
const split = require('split2');
const through = require('through2');
const dope = msg => ({
pid: process.pid,
time: new Date().getTime(),
level: /Error/.test(msg) ? 3 : 30,
@wilensky
wilensky / video2gif.sh
Created May 16, 2020 20:51
Convert video file to GIF with FFMPEG
ffmpeg -i in.mp4 -r 15 -vf scale=512:-1 -ss 00:00:04 -to 00:00:12 out.gif
@wilensky
wilensky / deploy.sh
Created November 22, 2017 09:11
Symfony deployment script
#!/bin/bash
ENVIRONMENT="prod";
if [ "$3" != "" ]; then
ENVIRONMENT=$3;
fi
if [ "$2" == "" ]; then
echo "Repository URL is mandatory!";
@wilensky
wilensky / php7_doctrine_native_pagination.php
Last active March 30, 2017 07:11 — forked from peterjmit/doctrine_native_pagination.php
Helper function for paginating with PHP7 and native Doctrine class
<?php
use Doctrine\ORM\Query;
use Doctrine\ORM\Tools\Pagination\Paginator;
// ------------------- //
public function paginate(Query $query, int $page = 1, int $limit = 10, bool $fetchJoinCollection = true)
{
// If we don't have a limit just return the result
@wilensky
wilensky / git_sm_co.sh
Last active October 15, 2019 06:10
Script checkouts each submodule on a given branch if latter exists (or fallback branch is used) and pulls if behind
#!/usr/bin/env bash
fetch=$(git fetch);
if [ "$(git show-ref refs/remotes/origin/$1)" ]; then # Checking branch for existence on remote
co=$(git checkout "$1"); # Checkouting branch that we checked for existence above
else
defaultFb="master"; # Default fallback
fb=${2:-$defaultFb} # Resulting fallback
echo "- Branch $1 does not exist. Switching to ${fb}";
@wilensky
wilensky / mencoder_video_merge.sh
Last active December 11, 2016 14:09
'mencoder' command to merge 1+ videos
mencoder -ovc copy -oac mp3lame GOPR3934.MP4 GP013934.MP4 GP023934.MP4 -o finalcut.avi
@wilensky
wilensky / tomato_hold_button_script_telnet.sh
Created August 7, 2016 10:47
Tomato firmware `telnet` enabling on button hold
[ $1 -ge 20 ] && telnetd -p 233 -l /bin/sh