Skip to content

Instantly share code, notes, and snippets.

View kayhadrin's full-sized avatar

David kayhadrin

  • AU-US in betweener
View GitHub Profile
@kayhadrin
kayhadrin / README-syncthing-restore-version.md
Last active January 12, 2023 04:38
Syncthing: bash script to move the latest version of all files from a given folder to a target folder

Syncthing: script to MOVE the latest version of all files from a given folder to a target folder

This is useful in case you've mistakenly deleted a very large folder and it takes forever to restore the files via "file copy". In this case, we're literally MOVING the old version files to the target location! So be careful, this cannot be reverted!

Usage:

./syncthing-restore-version.sh srcFolder dstFolder
@kayhadrin
kayhadrin / yes-im-listening-youtube-music.js
Last active November 26, 2020 08:41
Automatically click "Yes" to Youtube Music's "Are you still listening prompts". Use your browser's debugging console (https://www.w3schools.com/js/js_debugging.asp) to execute this code.
// Automatically click "Yes" to Youtube Music's "Are you still listening prompts"
// Use your browser's debugging console (https://www.w3schools.com/js/js_debugging.asp) to execute this code.
setInterval(function() {
var button = document.querySelector('.ytmusic-you-there-renderer #button');
button && button.click();
}, 500)
@kayhadrin
kayhadrin / changes.diff
Last active June 5, 2020 01:44
Babel types: flow libdef changes (related to https://github.com/babel/babel/pull/11671)
1,2c1,6
< // NOTE: This file is autogenerated. Do not modify.
< // See packages/babel-types/scripts/generators/flow.js for script used.
---
> /**
> * NOTE: This file is autogenerated. Do not modify.
> * See packages/babel-types/scripts/generators/flow.js for script used.
> *
> * @flow strict
> */
diff --git a/babel.config.js b/babel.config.js
index 56ee9e1..694d1fc 100644
--- a/babel.config.js
+++ b/babel.config.js
@@ -7,7 +7,13 @@ module.exports = function(api) {
'module:metro-react-native-babel-preset',
],
plugins: [
- 'babel-plugin-fbt', 'babel-plugin-fbt-runtime',
+ [
@kayhadrin
kayhadrin / extract-angular-1.x-DI.coffee
Created August 10, 2016 19:52
How to extract angular 1.x full dependency list
# # How to use?
# Put a breakpoint in angular.module() and when in there,
# Save the `modules` variable on the window object like `window.modules = modules`
# Then load the script below
# Then invoke: `angular.toJson(analyseModules(modules), true)`
analyseModule = (module) ->
module.map (provider) ->
[providerType, type, definition] = provider
@kayhadrin
kayhadrin / q-allSettled.js
Created July 29, 2016 20:09
Useful additions to $q
/**
* $q.allSettled returns a promise that is fulfilled with an array of promise state snapshots,
* but only after all the original promises have settled, i.e. become either fulfilled or rejected.
*
* This method is often used in order to execute a number of operations concurrently and be
* notified when they all finish, regardless of success or failure.
*
* @param promises array or object of promises
* @returns {Promise} when resolved will contain an an array or object of resolved or rejected promises.
* A resolved promise have the form { status: "fulfilled", value: value }. A rejected promise will have
@kayhadrin
kayhadrin / js-timeout-polyfill.js
Last active February 28, 2023 17:52
Nashorn setTimeout polyfill
/**
* js-timeout-polyfill
* @see https://blogs.oracle.com/nashorn/entry/setinterval_and_settimeout_javascript_functions
*/
(function (global) {
'use strict';
if (global.setTimeout ||
global.clearTimeout ||
global.setInterval ||
@kayhadrin
kayhadrin / pslist.bat
Last active April 5, 2016 20:24
Show details process list in command line
@echo off
rem Shows the list of current running processes
rem Run "WMIC path win32_process" to get further process details
WMIC path win32_process get Caption,Processid,Commandline
@kayhadrin
kayhadrin / triggerMouseEvent.js
Last active February 6, 2023 16:49
Trigger mouse event programmatically. Useful to simulate mouse wheel events.
/**
* Simulate a mouse event to a given DOM element
* @param {string, WebElement} elem
* @param {string} evtName Event name
* @param {object} eventInitProps Properties to set on the mouse event
*/
function triggerMouseEvent(elem, evtName, eventInitProps) {
return browser.executeScript(function(_elem, _evtName, _eventInitProps) {
var $ = window.jQuery;
elem = $(_elem);
@kayhadrin
kayhadrin / jquery-trackScroll.js
Created December 1, 2015 08:52
jQuery plugin to raise custom scroll_vertical and scroll_horizontal events
/**
* Simple plugin to track scroll events and trigger a custom jQuery event (scroll_vertical or scroll_horizontal)
* when the corresponding type of scroll has happened.
* Event handlers can receive the original scroll event and the scroll delta as second values.
* e.g. function(jqEvent, scrollEvent, delta)
*
* To stop this, unbind the 'scroll.trackScroll.vertical' or 'scroll.trackScroll.horizontal' event
* @param {string} direction Scroll direction to track
* @return {jQuery}
*/