• Sep 13, 2023 •C S
0 likes • 2 views
/** * @param {number[]} nums * @return {boolean} */ var containsDuplicate = function(nums) { return new Set(nums).size !== nums.length };
• Mar 11, 2021 •C S
import { configureStore } from "@reduxjs/toolkit"; import { combineReducers } from "redux"; import profile from "./profile"; import auth from "./auth"; import alert from "./alert"; const reducer = combineReducers({ profile, auth, alert, }); const store = configureStore({ reducer }); export default store;
• May 17, 2021 •LeifMessinger
//Upvotes comments according to a regex pattern. I tried it out on https://www.reddit.com/r/VALORANT/comments/ne74n4/please_admire_this_clip_precise_gunplay_btw/ //Known bugs: //If a comment was already upvoted, it gets downvoted //For some reason, it has around a 50-70% success rate. The case insensitive bit works, but I think some of the query selector stuff gets changed. Still, 50% is good let comments = document.getElementsByClassName("_3tw__eCCe7j-epNCKGXUKk"); //Comment class let commentsToUpvote = []; const regexToMatch = /wtf/gi; for(let comment of comments){ let text = comment.querySelector("._1qeIAgB0cPwnLhDF9XSiJM"); //Comment content class if(text == undefined){ continue; } text = text.textContent; if(regexToMatch.test(text)){ console.log(text); commentsToUpvote.push(comment); } } function upvote(comment){ console.log(comment.querySelector(".icon-upvote")); //Just showing you what it's doing comment.querySelector(".icon-upvote").click(); } function slowRecurse(){ let comment = commentsToUpvote.pop(); //It's gonna go bottom to top but whatever if(comment != undefined){ upvote(comment); setTimeout(slowRecurse,500); } } slowRecurse();
• Nov 20, 2022 •Helper
new StringBuilder(hi).reverse().toString()
• Jan 25, 2023 •C S
0 likes • 24 views
const ResponsiveCardImg = styled(Card.Img)` // For screens wider than 768px @media(min-width: 768px) { // Your responsive styles here. } // For screens smaller than 768px @media(max-width: 768px) { // Your responsive styles here. } ` export default function App() { return ( <MainContainer> <Container> <Card text='white' bg='dark' style={styles.mainCard}> <ResponsiveCardImg style={styles.cardImage} onClick={handleClick} src={apeImage} alt='Degenerate Ape Academy' /> <Card.Body> <Card.Title className='text-center' as='h2'> {apeId} </Card.Title> </Card.Body> </Card> </Container> </MainContainer> ); }
• Nov 19, 2022 •CodeCatch
0 likes • 1 view
const levenshteinDistance = (s, t) => { if (!s.length) return t.length; if (!t.length) return s.length; const arr = []; for (let i = 0; i <= t.length; i++) { arr[i] = [i]; for (let j = 1; j <= s.length; j++) { arr[i][j] = i === 0 ? j : Math.min( arr[i - 1][j] + 1, arr[i][j - 1] + 1, arr[i - 1][j - 1] + (s[j - 1] === t[i - 1] ? 0 : 1) ); } } return arr[t.length][s.length]; }; levenshteinDistance('duck', 'dark'); // 2