Skip to content

Instantly share code, notes, and snippets.

@dhoko
dhoko / templateSettings.js
Created February 18, 2014 14:37
Lodash/underscore custom template settings with {{ }}
_.templateSettings = {
evaluate: /{{([\s\S]+?)}}/g,
interpolate: /{{=([\s\S]+?)}}/g,
escape: /{{-([\s\S]+?)}}/g
};
@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 / listDirectives.js
Last active November 13, 2019 06:33
AngularJs - get list of all registered directives
const listDirectivesApp = () => {
const listDirectives = name => {
return angular
.module(name)
._invokeQueue
.filter(item => 'directive' === item[1])
.map(item => item[2][0]);
};
return angular
@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 / 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;
/*
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 / 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) {