This file contains 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
/** | |
* Calculates whether an HTML element has been viewed, according to the criteria in the options argument. | |
* @param {Object} options An object with the following properties: | |
* minArean {Number} The minimum % of visible area to qualify as viewed. | |
* minWidth {Number} The minimum % of visible width to qualify as viewed. | |
* minHeight {Number} The minimum % of visible height to qualify as viewed. | |
* @param {Function} next An optional callback function. | |
* @returns {Boolean} Whether the element has been viewed. | |
*/ |
This file contains 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
import web3 from 'web3' | |
var abi = '' /* TODO: abi generated by the compiler */ | |
var ZombieFeedingContract = web3.eth.contract(abi) | |
var contractAddress = '' /* TODO: our contract address on Ethereum after deploying */ | |
var ZombieFeeding = ZombieFeedingContract.at(contractAddress) | |
// Assuming we have our zombie's ID and the kitty ID we want to attack | |
let zombieId = 1 | |
let kittyId = 1 |
This file contains 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
<?php // https://www.testdome.com/questions/php/palindrome/7320?questionIds=7320,11840&generatorId=30&type=fromtest&testDifficulty=Easy | |
class Palindrome { | |
public static function isPalindrome($word) { | |
$word = str_split(strtolower($word)); | |
for($i = 0; $i < ceil(count($word)/2); $i++) { | |
$leftChar = $word[$i]; | |
$rightChar = $word[count($word)-$i-1]; | |
if($leftChar !== $rightChar) { | |
return FALSE; | |
} |
This file contains 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 MAX_PERIODS = 52 | |
const MARGIN_PER_PERIOD = 0.05 | |
function calc(v, t) { | |
console.log(v) | |
if (t === 0) return v; | |
const n = (v * MARGIN_PER_PERIOD) + v | |
return calc(n, --t) | |
} |
This file contains 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 ALLOW_AUTO_PURCHASE = false | |
const CHECKOUT_URL = 'https://www.amazon.com/gp/buy/shipoptionselect/handlers/display.html?hasWorkingJavascript=1' | |
const { pathname } = location | |
const isShipOptionPage = /buy\/shipoptionselect/.test(pathname) | |
const isPaySelectPage = /buy\/payselect/.test(pathname) | |
const isPurchasePage = /buy\/spc/.test(pathname) | |
const isThankYouPage = /buy\/thankyou/.test(pathname) | |
let attemptNum = 1 |
This file contains 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 AWS = require('aws-sdk') | |
const s3 = new AWS.S3({ apiVersion: '2006-03-01', region: 'us-east-1' }) | |
const params = { | |
Bucket: 'YOUR_BUCKET_NAME' | |
} | |
/** | |
* `s3.listObjects` has a max result set size of 1000. This function iterates to list all objects in the bucket. | |
* | |
* @example |
This file contains 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
/** | |
* Disposes of any Three.js object (mesh, material, etc.) and any disposable objects in the hierarchy below it by doing a depth-first search. | |
* @param {Boolean} showLogging Output logs useful for troubleshooting. | |
* @example | |
* const trash = HierarchyDisposal(true) | |
* trash([some three.js object]) | |
*/ | |
function HierarchyDisposal (showLogging = false) { | |
const bag = [] |
This file contains 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
/** | |
* Custom hook for setting up an intersection observer on a DOM element to determine its visibility relative to a specified viewport or the default viewport. Implements the native `IntersectionObserver` JavaScript class. | |
* | |
* @param {React.RefObject} ref - Required. The React ref object pointing | |
* @param {Object} options - The options for setting up the observer. | |
to the DOM element to observe. | |
* @param {Element|null} [options.root=null] - The element that is used as the viewport for checking visibility of the target. Defaults to the browser viewport if not specified. | |
* @param {string} [options.rootMargin="0px"] - The margin around the viewport or "root". Can have values similar to the CSS margin property, e.g. "10px 20px 30px 40px" (top, right, bottom, left). | |
* @param {number} [options.threshold=0.5] - A single number or array of numbers indicating at what percentage of the target's visibility the observer's callback should execute. Ranges from 0 to 1. | |
* @returns {boolean} True if a current intere |