Skip to content

Instantly share code, notes, and snippets.

View shreyanshp-cactus's full-sized avatar

Shreyansh Panchal shreyanshp-cactus

View GitHub Profile
@shreyanshp-cactus
shreyanshp-cactus / canvas-tracker.js
Created May 12, 2025 06:29
wrap canvas context methods
const canvas = document.getElementById('myCanvas');
const ctx = canvas.getContext('2d');
// Save the original method
const originalFillRect = ctx.fillRect;
// Override it
ctx.fillRect = function(x, y, width, height) {
console.log("Called fillRect with:", x, y, width, height);
// middleware.js
import { NextResponse } from 'next/server';
export function middleware(request) {
// Get the referrer and target URL
const referrer = request.headers.get('referer') || '';
const url = request.nextUrl.clone();
// Check if this is a navigation to an external site
if (url.pathname.startsWith('/api/outbound')) {
@shreyanshp-cactus
shreyanshp-cactus / part1-guidelines.md
Last active February 7, 2025 09:52
Prompt Guidelines

Principles of Prompting

1. Write clear and specific instructions

short != clear, Write as much as you would like to add.
Tactic 1: Use delimiters
```
Triple quotes: “””
Triple backticks: ```,

Triple dashes: ---,

<?php
class DownloadDiscoveryArticleCommand
{
public $batchSize = 10;
public function handle()
{
$totalItems = $this->getTotalJournalsFromDiscovery();
<?php
return [
'af' => [ 'calling_code' => '+93', 'name' => 'Afghanistan'],
'ax' => [ 'calling_code' => '', 'name' => 'Aland Islands'],
'al' => [ 'calling_code' => '+355', 'name' => 'Albania'],
'dz' => [ 'calling_code' => '+213', 'name' => 'Algeria'],
'as' => [ 'calling_code' => '+1', 'name' => 'American Samoa'],
'ad' => [ 'calling_code' => '+376', 'name' => 'Andorra'],
'ao' => [ 'calling_code' => '+244', 'name' => 'Angola'],