This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
// Copy styles from one ASS subtitle file to another by copying every section above [Events] | |
const fs = require('fs').promises | |
const sourcePath = process.argv[2] | |
const targetPath = process.argv[3] | |
async function main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* VS Code - Smaller Activity bar, larger sidebar (left side only) | |
* | |
* To enable: | |
* - Install https://marketplace.visualstudio.com/items?itemName=be5invis.vscode-custom-css | |
* - Save content of this file somewhere, CUSTOMCSSPATH. | |
* - Add to VS Code user settings: | |
* "vscode_custom_css.imports": ["file://CUSTOMCSSPATH"], | |
* "vscode_custom_css.policy": true, | |
* - $ sudo -E code --user-data-dir=$HOME/.config/Code/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
################################################################################ | |
# | |
# Replace marked variables with environment variables (in-place version). | |
# Author: lleaff | |
# Version: 1.0 | |
# | |
################################################################################ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Generate JavaScript dependency graph with Madge and open in default SVG viewer | |
function random_filename() { | |
local length=${1:-10} | |
head -c $(( $length * 100 )) /dev/urandom | \ | |
tr -dc 'a-zA-Z0-9-_' | \ | |
head -c $length | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
self.DEBUG_ON = true; | |
function DEBUG(...args) { | |
if (!DEBUG_ON) { return; } | |
const stack = (new Error().stack).match(/\s+at .*\s+at ([^\(]+)/); | |
const caller = stack && stack[1] ? stack[1].replace(/\s+$/, '') : 'top_level'; | |
(console.debug || console.log)(`[DEBUG@(${caller})]:`, ...args); | |
} | |
Object.defineProperty(Object.prototype, 'DEBUG', { | |
value: function DEBUG_PIPE(msg, ...args) { | |
DEBUG(msg, this, ...args); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Compile: | |
* gcc -Wall -Werror -pedantic -ansi -std=c89 readnum.c | |
*/ | |
#include <stdio.h> | |
#include <string.h> | |
#include <stdlib.h> | |
#include <unistd.h> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const last = a => a[a.length - 1]; | |
const mergeConsecutive = (arr, el) => (arr.length <= 1) ? | |
arr : | |
arr.slice(1).reduce((p, v) => v === el && last(p) === v ? | |
p : | |
[...p, v], [arr[0]]); | |
const mergeConsecutiveElements = arr => (arr.length <= 1) ? | |
arr : | |
arr.slice(1).reduce((p, v) => last(p) === v ? p : [...p, v], [arr[0]]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Discord - Open chat in popup | |
// @namespace lleaff | |
// @updateURL https://gist.github.com/lleaff/8514033dc8e54ce02d6adf3c2e46d8ff/raw/Discord_-_Open_chat_in_popup.user.js | |
// @supportURL https://gist.github.com/lleaff/8514033dc8e54ce02d6adf3c2e46d8ff#comments | |
// @match https://discordapp.com/channels/* | |
// @version 1 | |
// @run-at document-end | |
// @grant none | |
// @noframes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Slice an array every n elements. Don't leave out any elements from source array or | |
* empty spaces in the resulting slices. | |
* @example | |
* arraySliceEveryN([1,2,3,4,5,6,7], 3) | |
* //=> [[1,4,7],[2,5],[3,6]] | |
*/ | |
function arraySliceEveryN(array, n) { | |
let slices = Array(n); | |
const min_len = Math.floor(array.length / n); // Length without remaining elements |
NewerOlder