Skip to content

Instantly share code, notes, and snippets.

@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 / apple_touch_icons.html
Created October 18, 2016 09:31
HTML page Apple Touch icon `<link>`s
<!-- Apple Touch Icons -->
<link rel="apple-touch-icon" href="/images/apple-touch-icon-60x60.png" />
<link rel="apple-touch-icon" sizes="76x76" href="/images/apple-touch-icon-76x76.png">
<link rel="apple-touch-icon" sizes="120x120" href="/images/apple-touch-icon-120x120.png">
<link rel="apple-touch-icon" sizes="152x152" href="/images/apple-touch-icon-152x152.png">
<!-- End of Apple Touch Icons -->
@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
@wilensky
wilensky / tomato_HPLJP1006_hotplug.sh
Last active August 7, 2016 10:50
Tomato firmware hotplug script for HP LaserJet P1006 printer
# Printer identity needs to be read separately by another hotplug script which prints id of plugged hardware
if [ $PRODUCT = "3f0/3e17/100" ]; then # `3f0/3e17/100` - printer identity
if [ $ACTION = "add" ]; then
sleep 1
cat /jffs/sihpP1006.dl > /dev/usb/lp0
fi
fi