From 36f57eb7cafef1d96e2a5b5392c2470efed797eb Mon Sep 17 00:00:00 2001 From: GitHub Action Date: Sat, 4 Nov 2023 06:05:31 +0000 Subject: [PATCH] Get recent pastes --- pastes/pastes_20231104060530.csv | 14248 +++++++++++++++++++++++++++++ 1 file changed, 14248 insertions(+) create mode 100644 pastes/pastes_20231104060530.csv diff --git a/pastes/pastes_20231104060530.csv b/pastes/pastes_20231104060530.csv new file mode 100644 index 0000000..686cc54 --- /dev/null +++ b/pastes/pastes_20231104060530.csv @@ -0,0 +1,14248 @@ +id,title,username,language,date,content +2ujGwcHF,268. Missing Number,micahbales,JavaScript,Saturday 4th of November 2023 12:48:18 AM CDT,"/* +* Problem statement: https://leetcode.com/problems/missing-number/ +* +* The obvious solution to this problem is to pre-sort the array and then iterate +* over it searching for the missing number. Unfortunately, this solution requires two +* iterations over the entire array, including a sort action that can be expensive +* depending on the implementation. +* +* There is an alternative solution here, if you are aware of the Gaussian Summation, +* which states that for any list of ordered numbers 1..n, the sum total of that list +* will be equal to (n * (n + 1)) / 2, where 'n' is the length of the list of numbers. +* This seems like a silly thing to expect someone to know in an interview. +* But it's a neat trick. +*/ + + +/* Trivial Solution By Pre-Sorting */ + +/** + * @param {number[]} nums + * @return {number} + */ +var missingNumber = function(nums) { + nums.sort((a,b) => a - b) + + let lastNum = -1 + for (let i = 0; i < nums.length; i++) { + if (nums[i] !== lastNum + 1) return nums[i] - 1 + lastNum = nums[i] + } + return lastNum + 1 +} + +/* Trick-Shot, feat. C.F. Gauss */ + +/** + * @param {number[]} nums + * @return {number} + */ +var missingNumber = function(nums) { + const n = nums.length + const expectedSum = (n * (n + 1)) / 2 + let actualSum = 0 + for (let i = 0; i < nums.length; i++) { + actualSum += nums[i] + } + return expectedSum - actualSum +}" +cAUrZUt1,BTC Wallet Credentials have been reset,VQ-Moe,GetText,Saturday 4th of November 2023 12:45:35 AM CDT,"Dear User +We have received a request to reset the login information for your Bitcoin wallet. If you did not make this request, please disregard this message. +Your new login credentials will be +josli45:KoE3dG1 on 159.223.212.34 +You can connect via SSH. +Regards + +BT371724" +7YbuQW8R,BTC Wallet Credentials have been reset,castlclass_20,GetText,Saturday 4th of November 2023 12:15:26 AM CDT,"Dear User +We have received a request to reset the login information for your Bitcoin wallet. If you did not make this request, please disregard this message. +Your new login credentials will be +rhydyllaqx:cYbxTP on 212.224.93.130 +You can connect via SSH . +Regards" +HNbEiTtX,Untitled,test12333,C++,Friday 3rd of November 2023 10:55:11 PM CDT,"std::uintptr_t util::FindPattern( const char* smodule, const char* pattern, bool only_text_or_code, bool format ) { + const auto mod_p = (uintptr_t)util::get_module_base_ansi( smodule ); + PIMAGE_DOS_HEADER pe_headers = (PIMAGE_DOS_HEADER)mod_p; + PIMAGE_NT_HEADERS new_pe_headers = PIMAGE_NT_HEADERS( (uint8_t*)( mod_p + pe_headers->e_lfanew ) ); + + DWORD dwSizeOfImage; + DWORD end; + uintptr_t begin; + + if ( only_text_or_code ) { + PIMAGE_SECTION_HEADER Section = IMAGE_FIRST_SECTION( new_pe_headers ); + + for ( WORD i = 0; i < new_pe_headers->FileHeader.NumberOfSections; i++ ) { + + if ( !fast_strcmp( (char*)Section->Name, "".code"" ) || !fast_strcmp( (char*)Section->Name, "".text"" ) ) { + + begin = Section->VirtualAddress; + dwSizeOfImage = Section->SizeOfRawData; + end = begin + dwSizeOfImage; + + //printf( ""%-8s\t%x\t%x\t%x\n"", Section->Name, Section->VirtualAddress, + // Section->PointerToRawData, Section->SizeOfRawData ); + + } + Section++; + } + } + + else { + begin = mod_p; + dwSizeOfImage = new_pe_headers->OptionalHeader.SizeOfImage; + end = begin + dwSizeOfImage; + } + + + if ( const auto result = reinterpret_cast( find_pattern_internal( begin, end, format ? ParseCombo( pattern ).c_str( ) : pattern ) ); result ) { + return result; + } + return NULL; +}" +6mZZpTLg,Koikatsu List Scraper V1.3,Skelun,JavaScript,Friday 3rd of November 2023 10:37:20 PM CDT,"/* -------------------------------------------------------------------- +-- Transforms embedded links into actual Hyperlinks +----------------------------------------------------------------------- */ + +function createHyperlink() { + var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); + + // Get the selected range + var range = sheet.getActiveRange(); + var richTextValues = range.getRichTextValues(); + + for (var i = 0; i < richTextValues.length; i++) { + for (var j = 0; j < richTextValues[0].length; j++) { + var textValue = richTextValues[i][j].getText(); + var link = richTextValues[i][j].getLinkUrl(); + + if (link) { + // Creates a hyperlink formula + var formula = '=HYPERLINK(""' + link + '"", ""Here"")'; + + // Set the formula in the cell + sheet.getRange(range.getRow() + i, range.getColumn() + j).setFormula(formula); + } + } + } +} + +/* -------------------------------------------------------------------- +-- MOON RATING +----------------------------------------------------------------------- +-- I'm using this because it was the easier way +-- to simulate rating stars. +----------------------------------------------------------------------- */ + +function moonRating(number) { + + if (!isNaN(number)) { + var votes; + + // Is it an interger? + if (number % 1 === 0) { + votes=""πŸŒ•"".repeat(number); + votes+=""πŸŒ‘"".repeat(5-number); + + // Or is it a float? + } else { + let n = Math.floor(number); + votes=""πŸŒ•"".repeat(n); + votes+=""πŸŒ—""; + votes+=""πŸŒ‘"".repeat(4-n); + } + return votes; + } else { + // If no votes + return ""------"" + } +} + +/* -------------------------------------------------------------------- +-- Scraping data using Cheerio library +-- (https://github.com/tani/cheeriogs) +-- Script ID: 1ReeQ6WO8kKNxoaA_O0XEQ589cIrRvEBA9qcWpNqdOP17i47u6N9M5Xh0 +----------------------------------------------------------------------- */ + +// Cheerio method to scrape +function getContent(url) { + return UrlFetchApp.fetch(url).getContentText() +} + +/* -------------------------------------------------------------------- +-- Actual scrape function +----------------------------------------------------------------------- */ + +function scrapeData(force) { + + // Selects the active sheet + var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet(); + + // Get selected cells + var selectedRange = sheet.getActiveRange(); + + // Get the values from the selected cells + var selectedValues = selectedRange.getRichTextValues(); + + // Iterate through cells + for (var i = 0; i < selectedValues.length; i++) { + + // It assumes the URLs are in the first column of the selected column + var urlFromLink = selectedValues[i][0].getLinkUrl(); + var urlFromCellValue = selectedValues[i][0].getText(); // Get text value from the cell + + // Check if there is a link URL, and use it if available; otherwise, use the URL from the cell value + var url = urlFromLink ? urlFromLink : urlFromCellValue; + + // If the value is not empty... + if (url && isValidURL(url)) { + + // Grabs the HTML data + var content = getContent(url); + + // Parses the HTML data + var $ = Cheerio.load(content); + + /* -------------------------------------------------------------------- + -- [TITLE] + -------------------------------------------------------------------- */ + var threadTitle = $('h1.p-title-value'); + + var rawTitle = threadTitle.contents().filter(function() { + return this.type === 'text'; + }).text(); + + /* + var titleREGEX = /(.+?)\s*\[(.+?)\](?:\s*\[(.+?)\])?/.exec(rawTitle); + + // We should check if titleREGEX is not null before accessing its indices + if (titleREGEX) { + var title = titleREGEX[1]; + var version = titleREGEX[2]; + } else { + var title = ""Title Problem ⚠️""; + var version = ""Version Problem ⚠️""; + } + + var devBackup = titleREGEX[3] ? titleREGEX[3] + "" ❓"" : ""Not found ⚠️""; + + */ + + // Inspects the Title searching for what's inside the brackets and what's not + // it creates 3 captures groups: title, version and developer's name + var titleREGEX = /(.+?)\s*\[(.+?)\](?:\s*\[(.+?)\])?/.exec(rawTitle); + + // initialize variables + var title = ""Title N.F. ⚠️""; + var version = ""Version N.F. ⚠️""; + var devBackup = ""Dev N.F. ⚠️""; + + // Check if the regex has matched + if (titleREGEX) { + + // If it exists, the game title is the first capture group + title = titleREGEX && titleREGEX.length > 1 ? titleREGEX[1] : title; + + // The version will be in the second capture group, if it exists + version = titleREGEX.length > 2 && titleREGEX[2] ? titleREGEX[2] : version; + + // The dev backup information will be in the third capture group, if it exists + devBackup = titleREGEX.length > 3 && titleREGEX[3] ? titleREGEX[3] + "" ❓"" : devBackup; + + } else { + // If there's nothing extra, assumes it's only the title + title = rawTitle; + } + + + /* -------------------------------------------------------------------- + -- [STATUS] (ACTIVE - ABANDONED - ONHOLD) + -------------------------------------------------------------------- */ + // Default status + var status = 'Active'; + + // Search for ""Abandoned"" or ""Onhold"" + threadTitle.find('span').each(function() { + var spanText = $(this).text(); + if (['Completed','Abandoned','Onhold'].includes(spanText)) { + status = spanText; + return false; + } + }); + + /* -------------------------------------------------------------------- + -- [ENGINE] + ----------------------------------------------------------------------- */ + // If there's no engine info, it returns ""unknown"" + var engine = '⚠️ Unknown'; + + // Checks if there's one of these strings + threadTitle.find('span').each(function() { + var spanText = $(this).text(); + if (['ADRIFT','Flash','Java','Others','QSP','RAGS','RPGM',""Ren'Py"",'Tads','Unity','Unreal Engine','WebGL','Wolf RPG','HTML'].includes(spanText)) { + engine = spanText; + return false; // Stop searching once a match is found + } + }); + + /* -------------------------------------------------------------------- + -- [TAGS] + ----------------------------------------------------------------------- */ + // Selects the element containing the tags + var tagList = $('span.js-tagList'); + + // Grabs the tags and separate them by comma + var tags = tagList.find('a.tagItem').map(function() { + return $(this).text(); + }).get().join(', '); + + /* -------------------------------------------------------------------- + -- GAMEPLAY + ----------------------------------------------------------------------- */ + var gameplay; + + // Assumes the [Gameplay] type by using the tags + switch (true) { + case tags.includes('sandbox'): + gameplay = 'Sandbox'; + break; + case tags.includes('turn based combat'): + gameplay = 'TBC'; + break; + case tags.includes('management'): + gameplay = 'Management'; + break; + case tags.includes('simulator'): + gameplay = 'Simulator'; + break; + case tags.includes('rpg'): + gameplay = 'RPG'; + break; + default: + gameplay = 'Visual Novel'; + } + + /* -------------------------------------------------------------------- + -- - Thread [Start] Date + ----------------------------------------------------------------------- */ + + // Selects the first 'article' element + var firstArticle = $('article').first(); + + // Find the 'header.message-attribution' element + var messageAttributionHeader = firstArticle.find('header.message-attribution'); + + // Find the 'time' element with class 'u-dt' + var timeElement = messageAttributionHeader.find('time.u-dt'); + + // Check if the time element exists + if (timeElement.length > 0) { + // Extract the 'datetime' attribute + var start = timeElement.attr('datetime'); + start = start.split('T')[0]; // Get the date part only + + } else { + Logger.log(""