Skip to content

Instantly share code, notes, and snippets.

@HT-7
HT-7 / remove invalid characters.sh
Created March 14, 2023 15:33
This Linux command replaces characters of file names that Windows considers invalid with an underscore, to make the files accessible and manageable on Windows again. Renamed files are logged to record their original names.
rename -v "s/(:|\"|\*|\\|\||\&|\?|\%|\<|\>)/_/g" .* * |tee -a renamed_files.$(date +%Y%m%d%H%M%S).log
@HT-7
HT-7 / date_calculator.js
Last active June 29, 2022 23:10
JavaScript date calculator (backwards-compatible to ECMAscript 3)
var calcDate_data = {}; // initializing data object
function calcDate(date1, date2){
// memorize input to detect invalid input
calcDate_data.input1 = date1;
calcDate_data.input2 = date2;
// initiate date object
var dt_date1 = new Date(date1);
@HT-7
HT-7 / downloadDOM.js
Last active November 5, 2022 22:35
downloadDOM – Save pages as lightweight HTML documents with one click! A file name with domain name and time stamp is automatically generated.
function download(filename, text) {
var tmp_node = document.createElement('a');
tmp_node.setAttribute('href', 'data:text/plain;charset=utf-8,' + encodeURIComponent(text));
tmp_node.setAttribute('download', filename);
tmp_node.style.display = 'none';
document.body.appendChild(tmp_node);
tmp_node.click();
@HT-7
HT-7 / timerUI.js
Last active August 12, 2023 18:44
Web media timer
// == Dependencies ==
var mediaType; // for compatibility
var playerExists = false; // is set to true below if player exists
var checkMediaType_enabled = true; // for debugging purposes
var media_element = {}; // declaring as object
var tmp="",count=0; // initiating temporary variables used inside functions and loops
function checkMediaType() {
// checks whether it is a video or an audio tag
@HT-7
HT-7 / playback keyboard controls.js
Last active May 20, 2022 00:52
Playback keyboard controls (jumping, skipping, volume, and speed) for web media players which lack such controls natively.
// Playback keyboard controls script
// (currently only works on dedicated media pages)
// Configuration
var jump_distance_forward = 10; // Jump this many seconds forward using right arrow key.
var jump_distance_backward = 5; // Jump this many seconds backward using left arrow key.
var speed_step = 1/4; // Speed increased or decreased by this value using arrow keys up and down.
var volume_step = 1/10; // Volume increased or decreased by this value using +-.
var volume_step_fine = 1/100; // Volume increased or decreased by this value if below volume_step.
// Seek: 0 to 9 Reset the speed using "Insert".