Skip to content

Instantly share code, notes, and snippets.

View prashantthb's full-sized avatar
💭
I may be slow to respond.

Prashant Sudeep prashantthb

💭
I may be slow to respond.
  • new delhi
View GitHub Profile

I want to solve the following problem, but I’m stuck.
Please act as a “cognitive centrifuge.”

  1. Break the problem into exactly four numbered sub-problems.
  2. For each sub-problem, give me one concrete micro-action I can do in under 2 minutes that will either (a) make the problem smaller, or (b) give me new information.
  3. After the four micro-actions, add a one-line “momentum booster” I can say out loud to prime my brain to keep going.
  4. Format the whole thing so I can read it in <15 seconds.

Problem:

@prashantthb
prashantthb / payment_gateway.js
Last active March 27, 2024 20:01
Payment gateway sample code architecture plan
// Function to generate payment link
function generatePaymentLink(params: PaymentParams): Promise<PaymentLinkResponse> {
// Log the payment link generation request
log('Generating payment link for:', params);
// Call the payment gateway API to generate the payment link
const paymentLink = paymentGateway.generateLink(params);
// Handle success response
if (paymentLink) {
@prashantthb
prashantthb / timetracker.js
Created March 4, 2024 07:43
Time Tracking page view library JavaScript
// timetracker.js
(function () {
let startTime;
let isActive = true;
let elapsedTime = 0;
const sessionKey = `timetracker_${window.location.href}`;
const lastSavedTimestampKey = `lastSavedTimestamp_${window.location.href}`;
function startTracking() {
@prashantthb
prashantthb / timetracking.js
Created March 4, 2024 07:42
Time Tracking Page view time
// TimeMe.initialize({
// currentPageName: "index-page", // current page
// idleTimeoutInSeconds: 60, // stop recording time due to inactivity
// });
// TimeMe.callAfterTimeElapsedInSeconds(5, function(){
// console.log("The user has been using the page for 5 seconds! Let's prompt them with something.");
// });
@prashantthb
prashantthb / loops.js
Created July 25, 2023 07:24
Loops problems
// Question 1
for (let i = 1; i <= 10; i++) {
console.log(i);
}
// Question 2
for (let i = 2; i <= 20; i += 2) {
console.log(i);
}
@prashantthb
prashantthb / functions.js
Created July 25, 2023 07:23
Functions practice solutions
// Question 1
//Write a function that takes two numbers as input and returns their sum.
function addNumbers(a, b) {
return a + b;
}
// Question 2
//Write a function that calculates the factorial of a given positive integer.
function factorial(n) {
if (n === 0 || n === 1) return 1;