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
// When viewing cruise listings on vacations to go, the sailing dates only include the month and day. | |
// This script can get pasted into Chrome's browser console to include the day of the week | |
// For example, to easily view which cruises leave on a specific day of the week such as Thursday | |
$$('td.dt').forEach(td => { | |
var textContent = td.textContent.trim(); | |
if (!/\d/.test(textContent)) { | |
// return if no numbers in the string, invalid date | |
return; | |
} |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>GPT DEFINE REQUEST DISPLAY</title> | |
<script async="async" src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script> | |
<script> | |
window.googletag = window.googletag || { cmd: [] }; |
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
/* | |
Original Reddit Thread | |
https://www.reddit.com/r/learnjavascript/comments/m1fwq5/im_learning_javascript_and_desperately_need_help/ | |
*/ | |
// The child’s game, War, consists of two players each having a deck of cards. | |
// For each play, each person turns over the top card in his or her deck. | |
// The higher card wins that round of play and the winner takes both cards. | |
// The game continues until one person has all the cards and the other has none. | |
// Create a program that simulates a modified game of War. |
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
/* | |
These javascript functions allow for converting from numbers to letters or from letters to number | |
I am using these functions to increment channels in a firebase realtime db using numbers as letters | |
going beyond 26 letters in the alphabet | |
For example 0 => A or 26 => AA similar to spreadsheet naming | |
numberToLetters(123) => "DT" | |
lettersToNumber('DT') => 123 |
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 react wipes ad slots from the DOM | |
this code is one option to detect when ad slots have been wiped by react | |
*/ | |
const slotsWiped = []; | |
/** | |
* Checks for wiped ad slots from react | |
* |
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
/* | |
Isn't it nice when devs use the same version of node when building on a project | |
I was searching for a way to enforce .nvmrc before running npm install | |
There was an npm package | |
-node-version, but do we really want another dependency in our projects | |
Add the following line inside of package.json | |
"preinstall": "node ./enforceNodeVersion" |
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
// GPT Bookmarklet | |
// javascript:function init(){let n,e;function t(){const n=$(this).attr("id");e.text(n)}function i(){const n=$(this).text(),e=(t=n,function(n,e){for(let t=0;t<n.length;t++)if(e(n[t]))return n[t]}(window.googletag.pubads().getSlots(),n=>n.getSlotElementId()===t));var t;if(e){const n=e.getResponseInformation();!function(n){const{slot:e,slotId:t,adUnitPath:i,advertiserId:o,campaignId:l,lineItemId:d,creativeId:a,sizes:r,slotTargetingKeys:g,serviceTargetingKeys:s,networkId:p}=n;$("#gpt_debug_overlay").html(`\n <div id="gpt_debug_underlay"></div>\n <ul>\n <button id="gpt_debug_close_overlay">CLOSE X</button>\n <li><b>Slot ID:</b> ${t}</li>\n <li><b>Ad Unit Path:</b> ${i}</li>\n <li><b>Advertiser ID: </b><a href="https://www.google.com/dfp/${p}#delivery/ListOrders/companyId=${o}" target="_blank">${o}</a></li>\n <li><b>Campaign ID: </b><a href="https://www.google.com/dfp/${p}#delivery/OrderDetail/orderId=${l}" target="_blank">${l}</a></li>\n <li>< |
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 open = window.XMLHttpRequest.prototype.open; | |
function openReplacement(method, url) { | |
if (url.indexOf('https://securepubads.g.doubleclick.net/gampad/ads?') > -1) { | |
this.onreadystatechange = function() { | |
if (this.readyState === 4) { | |
if (!this.status) { | |
console.log('BAD REQUEST'); | |
} | |
if (url.indexOf('&trunc=1') > -1) { |
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
iii |