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
// SPDX-License-Identifier: MIT | |
pragma solidity >=0.7.0 <0.9.0; | |
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/token/ERC721/ERC721.sol"; | |
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/utils/Counters.sol"; | |
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/access/AccessControl.sol"; | |
import "https://raw.githubusercontent.com/OpenZeppelin/openzeppelin-contracts/master/contracts/utils/Context.sol"; | |
contract MyNFT is Context, AccessControl, ERC721 { |
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 simpleMovingAverage(prices, window = 5, n = Infinity) { | |
if (!prices || prices.length < window) { | |
return []; | |
} | |
let index = window - 1; | |
const length = prices.length + 1; | |
const simpleMovingAverages = []; |
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 inputArray = [ | |
{ | |
squareMeters: 200, | |
priceInDollars: 190000 | |
}, | |
{ | |
squareMeters: 100, | |
priceInDollars: 90000 | |
}, | |
{ |
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
<dialog open> | |
<form method="dialog"> | |
<p>Do you want to confirm your action?</p> | |
<div class="right"> | |
<input class="btn" type="submit" value="Ok" /> | |
<input class ="btn" type="submit" value="Cancel" /> | |
</div> | |
</form> | |
</dialog> |
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 getCheering(followers) { | |
// If you were to switch over followers, you'd be surprised, | |
// because you'd always hit the default case. | |
// By switching over true, all cases get evaluated properly, although they | |
// contain numeric ranges! | |
switch (true) { | |
case followers >= 2000: | |
return "Wow, I'm speechless. I'm so happy, thank you!!!"; | |
case followers >= 1000: | |
return "Wow, this is so great!"; |
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
// Iterating over the array with each individual element at hand while separately | |
// keeping track of the index. | |
let i = 0; | |
for (const element of array) { | |
console.log(i++, element); | |
} | |
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 dict = {}; | |
dict.__proto__; // => {} | |
console.log(dict.hasOwnProperty); // => f hasOwnProperty() {} | |
const emptyDict = Object.create(null); | |
emptyDict.__proto__; // => undefined | |
emptyDict.hasOwnProperty; // => undefined | |
// ❗️ Anyone can modify the object prototype from the outside |
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
FROM public.ecr.aws/lambda/nodejs:12 | |
COPY package*.json ./ | |
RUN npm install | |
COPY index.js ./ | |
CMD [ "index.handler" ] |
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
node_modules/ | |
README.md |
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
type AnyFunc = (...args: any) => any; | |
export function once(func: AnyFunc): AnyFunc { | |
let alreadyCalled = false; | |
return (...args: any[]): any => { | |
if (alreadyCalled) { | |
return undefined; | |
} | |
alreadyCalled = true; |
NewerOlder