Skip to content

Instantly share code, notes, and snippets.

View omrilotan's full-sized avatar

omrilotan omrilotan

View GitHub Profile
@omrilotan
omrilotan / hello-world.svg
Last active October 6, 2022 00:36
Rick HTML in SVG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@omrilotan
omrilotan / getDOMChangelog.js
Last active July 16, 2020 14:47
Get DOM tree modification Changelog
/**
* @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
@omrilotan
omrilotan / crawlerip.js
Created May 27, 2020 13:54
Verify by reverse DNS of crawlers identity
const { reverse } = require('dns')
const check = ip => new Promise(
(resolve, reject) =>
addresses.includes(ip) || reverse(
ip,
(error, hostnames) => error
? reject(error)
: resolve(
hostnames.some(
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
/**
* Add a breadcrumb to "interactionTrail" array
* @param {Event} event
*/
function collectBreadcrumb({ type, target }) {
const { tagName, attributes = [] } = target;
const breadcrumb = {
type,
// Turn the event target into a descriptive object
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
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'),
};
const { code, details } = error;
Object.assign(record, { code, details });
...
sendError(record);
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',
};
record.metadata = {
url: document.location.href,
referrer: document.referrer,
cookie: navigator.cookieEnabled ? document.cookie : 'disabled',
language: navigator.language,
connection: navigator.connection.effectiveType,
hasFocus: document.hasFocus(),
readyState: document.readyState,
secondsIn: Math.round(performance.now() / 1000), // page age in seconds