This file contains hidden or 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
| /* Polyfill indexOf. */ | |
| var indexOf; | |
| if (typeof Array.prototype.indexOf === 'function') { | |
| indexOf = function (haystack, needle) { | |
| return haystack.indexOf(needle); | |
| }; | |
| } else { | |
| indexOf = function (haystack, needle) { | |
| var i = 0, length = haystack.length, idx = -1, found = false; |
This file contains hidden or 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
| # Created by https://www.gitignore.io/api/node,bower,osx,linux,windows,dropbox,sass,less,grunt,sublimetext,code | |
| ### Node ### | |
| # Logs | |
| logs | |
| *.log | |
| npm-debug.log* | |
| # Runtime data |
This file contains hidden or 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
| // Sometimes this should use location.href | |
| let params = (new URL(document.location)).searchParams; | |
| let name = params.get('name'); // is the string "Jonathan Smith". | |
| let age = parseInt(params.get('age')); // is the number 18 |
This file contains hidden or 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 a = document.createElement('a'); | |
| const ele = document.querySelector('canvas'); | |
| a.download = 'img.png'; | |
| a.addEventListener('click', () => { | |
| a.href = ele?.toDataURL("image/png"); | |
| }) | |
| a.click(); |
This file contains hidden or 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
| .truncate { | |
| text-overflow: ellipsis; | |
| overflow: hidden; | |
| white-space: nowrap; | |
| // your style, like max-width: 100px; | |
| } |
This file contains hidden or 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
| function copyToClipboard(str) { | |
| if (!str) { | |
| return; | |
| } | |
| // input element cannot keep '\n', so you can turn to textarea | |
| const inputEl = document.createElement('textarea'); | |
| inputEl.value = str; | |
| inputEl.style.cssText = 'position: absolute; top: -9999px; left: -9999px;'; | |
| document.body.appendChild(inputEl); | |
| inputEl.select(); |
This file contains hidden or 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
| [user] | |
| name = xxxx | |
| email = xxxx@example.com | |
| [alias] | |
| co = checkout | |
| st = status | |
| ci = commit | |
| br = branch | |
| ps = push | |
| pl = pull |
This file contains hidden or 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
| function detectWhetherElementScrollToEnd(element) { | |
| const { scrollLeft, scrollTop, offsetWidth, offsetHeight, scrollWidth, scrollHeight } = element; | |
| if (scrollTop === 0) { | |
| return 'scroll to top'; | |
| } | |
| if (scrollTop + offsetHeight >= scrollHeight) { | |
| return 'scroll to end'; | |
| } | |
| if (scrollLeft === 0) { | |
| return 'scroll to left'; |
This file contains hidden or 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
| Promise.limitAll = function(promises, limit) { | |
| return new Promise(resolve => { | |
| let resolvedCount = 0; | |
| let count = 0; | |
| let res = []; | |
| const len = promises.length; | |
| function next(p, index) { | |
| p().then(r => { | |
| res[index] = r; |
This file contains hidden or 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
| rundll32.exe user32.dll LockWorkStation |