Skip to content

Instantly share code, notes, and snippets.

@dhoko
dhoko / fetch-all-remote-branches.sh
Created December 2, 2020 15:02
Create a local copy of all remote branches for a repository
git ls-remote --heads | awk -F '/' '{ print $NF }' | while read -r name; do
echo "[${name}]";
git fetch origin "${name}:${name}";
done
git gc --prune=now
# Generate hex code for quotes
echo '"' | od -A n -t x1
@dhoko
dhoko / resizeZipImg.sh
Created February 7, 2019 13:36
Resize Zip/rar with images
#!/usr/bin/env bash
set -eo pipefail
IFS=$'\n'
function getExtension {
local file =$(basename -- "$1");
echo "${1##*.}";
}
function convertImages {
cd "$1";
@dhoko
dhoko / resizeHD.bash
Last active December 1, 2018 16:56
Resize a video (mp4/wmv) to HD (720p)
#!/bin/bash
set -eo pipefail
FILENAME=$(basename -- "$1");
EXT="${FILENAME##*.}";
NAME="${FILENAME%.*}";
OUTPUT=$(echo "$NAME-2.$EXT");
echo $FILENAME;
echo $OUTPUT;
@dhoko
dhoko / menacheGithubBranches.js
Created June 11, 2018 13:52
Remove merged branches
{
const list = $$('.js-branch-row');
const toRemove = list.filter((node) => {
return node.querySelector('.State--purple');
});
toRemove.forEach((node) => {
node.querySelector('.State--purple').textContent = 'DONE'
});
if (!toRemove.length) {
/*
Source https://scastiel.gitlab.io/protonmail-theme-creator/
*/
body section.sidebar ul.menu li a,
body section.sidebar ul.menu li:hover a,
body section.sidebar ul.menu li a i.fa,
body section.sidebar ul.menu li:hover a i.fa,
body section.sidebar ul.menu li a button.fa-repeat,
body section.sidebar ul.menu li:hover button.fa-repeat,
@dhoko
dhoko / video2gif.sh
Last active April 15, 2019 13:47
Convert a video to gif (webm/mp4)
#!/bin/bash
#
inputFile=$1
FPS=15
WIDTH=$2
OUTPUT='output.gif';
PALETTE_OUTPUT='tmp_palette.png';
@dhoko
dhoko / remove-gihtub-branch.js
Created September 26, 2016 10:04
Remove :merged github
Array
.from($$('.state-merged'))
.map(node => node.parentElement.parentElement.querySelector('button'))
.forEach(node => node.click())
@dhoko
dhoko / int.string.js
Created August 12, 2016 15:09
Convert Uint8Array to a string
String.fromCharCode.apply(null, data);
// data = new Uint8Array...