copy/paste code snippets

Add a snippet

Don't know how to code but want to pretend like you do? Just press copy to clipboard to copy a custom code snippet you want. Then shortcut paste (command +v) it in the custom code step inside your TaskMagic app workflow.

Filter by:

Scraping almost infinite scroll page

This code executes a function to automatically scroll a webpage to the bottom

No items found.
Copy
function scrollToBottom() { // Function to check if we are at the bottom of the page function isAtBottom() { return (window.innerHeight + window.scrollY) >= document.body.offsetHeight; } // Function to perform the scrolling down function scrollStep() { window.scrollBy(0, 1000); // Scroll down by 1000 pixels if (!isAtBottom()) { setTimeout(scrollStep, 1000); // Wait 1 second before the next scroll } else { console.log('Reached the bottom of the page.'); } } // Start the scrolling scrollStep(); } // Call the function to start scrolling down scrollToBottom();

Get the Current URL

Gets the current URL of the browser window, and outputs the comment to the console, for example: "Current URL: https://www.taskmagic.com/snippet-submission-voting"

No items found.
Copy
(function() { // Get the current URL var currentURL = window.location.href; // Log the current URL to the console console.log("Current URL: " + currentURL); })();

Timestamp for Google Sheets

This is a timestamp step that you can use as a variable in your Google Sheets step. The formatting is (MM-DD-YYYY - HH:MM)

No items found.
Copy
// Get the current date and time var currentDateTime = new Date(); // Manually format the date and time in MM-DD-YYYY - HH:MM format var formattedDateTime = ("0" + (currentDateTime.getMonth() + 1)).slice(-2) + "-" + ("0" + currentDateTime.getDate()).slice(-2) + "-" + currentDateTime.getFullYear() + " - " + ("0" + currentDateTime.getHours()).slice(-2) + ":" + ("0" + currentDateTime.getMinutes()).slice(-2); // Return the formatted date and time return formattedDateTime;

Get data in user's clipboard

This code can be used in a custom JavaScript script to get text from the user's clipboard, allowing you to paste it anywhere else or store it in a variable or other location.

No items found.
Copy
const text = await navigator.clipboard.readText(); return text;

N/A

Use directly Java Script Get the current time and date

No items found.
Copy
fetchDateTime = async () => { const response = await fetch('https://worldtimeapi.org/api/timezone/Asia/Taipei'); const data = await response.json(); return data.datetime.split('.')[0]; // Returns the complete date and time YYYY-MM-DDTHH:MM:SS }; const dateTime = await fetchDateTime(); return dateTime; //Returns date and time as string directly

Scroll Up

Scroll up to the very top of the browser

No items found.
Copy

window.scrollTo({

top: 0,

behavior: 'smooth'

})

What I created by Making, with Making in terms of my work

I don't know what it does

No items found.
Copy
HANDLE h_File = CreateFile(L"testing.exe", GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); if (!h_File) { printf("\nERROR : Could not open the file specified\n"); } //Mapping Given EXE file to Memory HANDLE hMapObject = CreateFileMapping(h_File, NULL, PAGE_READONLY, 0, 0, NULL); LPVOID basepointer = (char*)MapViewOfFile(hMapObject, FILE_MAP_READ, 0, 0, 0); //PIMAGE_DOS_HEADER dos_header; PIMAGE_DOS_HEADER dos_header = (PIMAGE_DOS_HEADER)basepointer; printf("Magic number - %X\n", dos_header->e_magic); printf("DOS HEADER: IMAGE NT HEADER offset(Relative Address) - %X\n", dos_header->e_lfanew); //DOS header working fine... //PIMAGE_NT_HEADERS ntHeader; PIMAGE_NT_HEADERS nt_header = (PIMAGE_NT_HEADERS)((DWORD)basepointer + dos_header->e_lfanew); printf("NT HEADER: Signature %x\n", nt_header->Signature); PIMAGE_FILE_HEADER file_header = (PIMAGE_FILE_HEADER)((DWORD)basepointer + dos_header->e_lfanew + sizeof(nt_header->Signature)); printf("FILE HEADER: Machine %x\n", file_header->Machine); PIMAGE_OPTIONAL_HEADER optional_header = (PIMAGE_OPTIONAL_HEADER)((DWORD)basepointer + dos_header->e_lfanew + sizeof(nt_header->Signature) + sizeof(nt_header->FileHeader)); printf("OPTIONAL HEADER: Image Base %x\n", optional_header->ImageBase); PIMAGE_SECTION_HEADER section_header = (PIMAGE_SECTION_HEADER)((DWORD)basepointer + dos_header->e_lfanew + sizeof(nt_header->Signature) + sizeof(nt_header->FileHeader) + sizeof(nt_header->OptionalHeader)); DWORD numberofsections = file_header->NumberOfSections; printf("Section Header: Number of Sections %x\n", file_header->NumberOfSections); for (int j = 0; j < optional_header->NumberOfRvaAndSizes;j++) { printf("Data Directory: Virtual Address: %x\t\n", optional_header->DataDirectory[j].VirtualAddress); } DWORD RVAimport_directory = nt_header->OptionalHeader.DataDirectory[1].VirtualAddress; //printf("RVAimport_directory %x", RVAimport_directory); PIMAGE_SECTION_HEADER import_section = {}; for (int i = 1; i <= numberofsections; i++, section_header++) { printf("Section Header: Section Name %s\n", section_header->Name); if (RVAimport_directory >= section_header->VirtualAddress && RVAimport_directory < section_header->VirtualAddress + section_header->Misc.VirtualSize) { import_section = section_header; } //section_header += (DWORD)sizeof(PIMAGE_SECTION_HEADER); } DWORD import_table_offset = (DWORD)basepointer + import_section->PointerToRawData; //imageBaseAddress + pointerToRawDataOfTheSectionContainingRVAofInterest + (RVAofInterest - SectionContainingRVAofInterest.VirtualAddress importImageDescriptor = (PIMAGE_IMPORT_DESCRIPTOR)(import_table_offset + (nt_header->OptionalHeader.DataDirectory[1].VirtualAddress - import_section->VirtualAddress)); //DLL Imports for (;importImageDescriptor->Name != 0 ; importImageDescriptor++) { DWORD Imported_DLL = import_table_offset + (importImageDescriptor->Name - import_section->VirtualAddress); printf("Imported DLLs: %s\n", Imported_DLL);

Read URL and make a filename with date range out of it - Clockify Detailed Report

Read URL and make a filename out of it - Clockify Detailed Report. Before you have to choose a time range. Because you have to set it fresh, to show up in the url.

No items found.
Copy
async function checkAndExtractDates() { const currentURL = window.location.href; const detailedPattern = "https://app.clockify.me/reports/detailed?"; // Prüfen, ob die URL mit dem detaillierten Muster übereinstimmt if (!currentURL.startsWith(detailedPattern)) { return { error: "URL does not match the required pattern for Detailed report." }; } // Extrahieren der URL-Parameter const urlParams = new URLSearchParams(currentURL.split('?')[1]); const startString = urlParams.get('start'); const endString = urlParams.get('end'); // Prüfen, ob die start- und end-Parameter vorhanden sind if (!startString || !endString) { return { error: "Start or end date parameter is missing for Detailed report." }; } return { startString, endString }; } function formatDate(dateString) { try { const [year, month, day] = dateString.split('T')[0].split('-'); return `${day}_${month}_${year}`; } catch (error) { console.error("Error formatting date:", error); return null; } } function convertToFilename(startDate, endDate) { const startFormatted = formatDate(startDate); const endFormatted = formatDate(endDate); if (!startFormatted || !endFormatted) { return null; } return `xxxClockify_Time_Report_Detailed_${startFormatted}-${endFormatted}.xlsx`; } async function generateFilename() { const dates = await checkAndExtractDates(); if (dates.error) { return dates.error; } const { startString, endString } = dates; const filename = convertToFilename(startString, endString); if (!filename) { return "Error generating filename from dates for Detailed report."; } return filename; } // Return the generated filename or an error message return await generateFilename();

Read URL and make a filename with date range out of it - Clockify Summary Report

Read URL and make a filename out of it - Clockify Summary Report. Before you have to choose a time range. Because you have to set it fresh, to show up in the url.

No items found.
Copy
async function checkAndExtractDates() { const currentURL = window.location.href; const summaryPattern = "https://app.clockify.me/reports/summary?"; // Prüfen, ob die URL mit dem Summen-Muster übereinstimmt if (!currentURL.startsWith(summaryPattern)) { return { error: "URL does not match the required pattern for Summary report." }; } // Extrahieren der URL-Parameter const urlParams = new URLSearchParams(currentURL.split('?')[1]); const startString = urlParams.get('start'); const endString = urlParams.get('end'); // Prüfen, ob die start- und end-Parameter vorhanden sind if (!startString || !endString) { return { error: "Start or end date parameter is missing for Summary report." }; } return { startString, endString }; } function formatDate(dateString) { try { const [year, month, day] = dateString.split('T')[0].split('-'); return `${day}_${month}_${year}`; } catch (error) { console.error("Error formatting date:", error); return null; } } function convertToFilename(startDate, endDate) { const startFormatted = formatDate(startDate); const endFormatted = formatDate(endDate); if (!startFormatted || !endFormatted) { return null; } return `Clockify_Time_Report_Summary_${startFormatted}-${endFormatted}.xlsx`; } async function generateFilename() { const dates = await checkAndExtractDates(); if (dates.error) { return dates.error; } const { startString, endString } = dates; const filename = convertToFilename(startString, endString); if (!filename) { return "Error generating filename from dates for Summary report."; } return filename; } // Return the generated filename or an error message return await generateFilename();
Show more
Thank you! Your submission has been received!
Oops! Something went wrong while submitting the form.

Pulse

Easily manage your entire network on your terms.

Personly

A personalized, permission based email welcome video platform.

Ernestly

A micro-blogging platform for startups building in public.