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
/** | |
* This function listens for the Konami Code sequence and triggers a callback when detected. | |
* The Konami Code is a famous cheat sequence of button presses (↑↑↓↓←→←→BA) from 1980s Konami video games that unlocks hidden features or bonuses. | |
* @param {Function} callback - The function to call when the Konami Code is entered. | |
* @param {Object} [options={}] - Options for the listener. | |
* @param {boolean} [options.once=false] - If true, the listener will be removed after the first successful entry. | |
* @param {number} [options.timeout=0] - Time in milliseconds to reset the sequence if no key is pressed (must be >= 0). | |
* @param {HTMLElement|Document} [options.target=document] - The target element to attach the listener to. | |
* @returns {Function} A function to remove the event listener. | |
* @throws {TypeError} When callback is not a function or timeout is negative. |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
/** | |
* @example | |
* getDOMChangelog() | |
* | |
* at https://github.githubassets.com/assets/vendor-cd663c13.js:120:53592 | |
* at https://github.githubassets.com/assets/vendor-cd663c13.js:120:53557 | |
* at cn (https://github.githubassets.com/assets/frameworks-728fb339.js:1:78638) | |
* at on (https://github.githubassets.com/assets/frameworks-728fb339.js:1:77982) | |
* at https://github.githubassets.com/assets/github-bootstrap-59211cb2.js:16:285146 | |
* at https://github.githubassets.com/assets/github-bootstrap-59211cb2.js:1:15524 |
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 { reverse } = require('dns') | |
const check = ip => new Promise( | |
(resolve, reject) => | |
addresses.includes(ip) || reverse( | |
ip, | |
(error, hostnames) => error | |
? reject(error) | |
: resolve( | |
hostnames.some( |
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 load_nvm { | |
source "$NVM_DIR/nvm.sh" | |
if [[ ! -f "$HOME/dotfiles/.npm_completion.sh" ]]; then | |
npm completion >> ~/dotfiles/.npm_completion.sh | |
fi | |
source ~/dotfiles/.npm_completion.sh | |
} | |
if [ -f ".nvmrc" ]; then | |
# Load NVM if needed |
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 providers = [ | |
['googletagmanager.com', 'googletagmanager'], | |
['linkedin.com', 'linkedin'], | |
['d2c7xlmseob604.cloudfront.net', 'smartling'], | |
['d2fltix0v2e0sb.cloudfront.net', 'dev.to'], | |
]; | |
/** | |
* Get the name of the script provider where applicable | |
* @param {string} url |
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 request_metadata = { | |
user_agent: request.get('user-agent'), | |
ip: request.get('true-client-ip'), // provided by DNS service | |
country: request.get('cf-ipcountry'), // Cloudflare provides GeoIP for free! | |
is_known_crawler: isbot(request.get('user-agent')), | |
referrer: request.get('referer'), | |
}; |
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 { code, details } = error; | |
Object.assign(record, { code, details }); | |
... | |
sendError(record); |
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
async function userRefreshInbox({ username }) { | |
try { | |
const response = await getNewInboxItems(); | |
// Do the thing you are supposed to do | |
} catch (error) { | |
error.code = 'SOME_ELABORATE_FLOW'; | |
error.details = { | |
username, | |
flow: 'User refresh inbox', | |
}; |
NewerOlder