Skip to content

Instantly share code, notes, and snippets.

View ssv445's full-sized avatar

Shyam Verma ssv445

View GitHub Profile
@ssv445
ssv445 / DynamicIframe.tsx
Created February 28, 2025 04:53
Dynamically Embedding HTML in Next.js Using iframes: When working with dynamic HTML in Next.js, you might need to handle content that includes external scripts, stylesheets, and inline JavaScript. Instead of using dangerouslySetInnerHTML, which doesn’t execute scripts, a more effective solution is embedding the HTML inside an iframe.
"use client";
import { useEffect, useRef, useState } from "react";
const DynamicIframe = ({ htmlContent }: { htmlContent: string }) => {
const iframeRef = useRef<HTMLIFrameElement>(null);
const [height, setHeight] = useState("100px"); // Default height
useEffect(() => {
const handleMessage = (event: MessageEvent) => {
if (event.data.height) {
@ssv445
ssv445 / DirectusLoader.tsx
Created February 23, 2025 04:29 — forked from davidpp/DirectusLoader.tsx
NextJS image loader for Directus
import type { ImageLoaderProps } from 'next/image'
const imgDomain = process.env.NEXT_PUBLIC_IMG_DOMAIN ?? ''
interface DirectusImageProps {
fit?: 'cover' | 'contain' | 'inside' | 'outside'
}
export default function directusImageLoader({
src: imageID,
@ssv445
ssv445 / Twitter-Interest-List-Reset-Script.js
Last active August 25, 2025 22:52
Twitter Interest List Reset Script (One Liner)
const checkboxes = document.querySelectorAll('input[type=checkbox]');
let index = 0;
(function uncheckNext() { if (index >= checkboxes.length) return; try { if (checkboxes[index].checked) { checkboxes[index].click(); console.log(`Unchecked checkbox at index ${index}`); } else { console.log(`Checkbox at index ${index} is already unchecked`); } index++; setTimeout(uncheckNext, 1000); } catch (error) { console.error('Error while unchecking checkbox:', error); setTimeout(uncheckNext, 5000); } })();
@ssv445
ssv445 / UploadService.js
Created November 2, 2023 05:17
Uploading a file to AWS presignedUrl using streaming the given file as a Url
"use strict";
const axios = require("axios");
const https = require("https");
async function uploadFileToPresignedUrl(presignedUrl, fileUrl) {
const response = await axios({
method: "get",
url: fileUrl,
responseType: "stream",
httpsAgent: new https.Agent({ keepAlive: true }),
@ssv445
ssv445 / docker-compose-macm1.yml
Created September 19, 2023 16:52
.devcontainer/docker-compose-macm1.yml
version: '3'
services:
app:
build:
context: .
dockerfile: nodejs/Dockerfile
args:
# Update 'VARIANT' to pick an LTS version of Node.js: 16, 14, 12.
# Append -bullseye or -buster to pin to an OS version.
@ssv445
ssv445 / resume.json
Created May 2, 2023 12:19
resume.json
{
"$schema": "https://raw.githubusercontent.com/jsonresume/resume-schema/v1.0.0/schema.json",
"basics": {
"name": "Shyam Sunder Verma",
"label": "Lead & Manager, Full Stack Team",
"image": "",
"email": "[email protected]",
"phone": "9982231113",
"url": "",
"summary": "Shyam is passionate​ to​ problem solving, he eagerly learn​s and adapt to​ solve​ problems. \nHe leads his team by example and firmly believes in empathy & innovation driven teams.\nHe​ represented Ready Bytes in the​ delegation​ of​ NASSCOM’s​ first​ India-US​ Startup​ Konnect​. (2015)\n\nShyam founded Ready Bytes in 2009. In last 12 years it have built more than 10+ web/mobile products. \n● PayPlans: Worlds #1 Joomla Payment Component (2009-2017, Sold)\n● Products Review​ Analysis & Recommendation Engine​ ReadyViews​ (2015-2018 Shutdown)\n● Exchange​ Rate​ analysis​ platform​ ExchangeRateIQ​ (2016-2018, Sold)\n● 15+​ mobile​ apps​ in​ last​ years (2015-Present)\n\nReady Bytes have worked for clients as well
@ssv445
ssv445 / git-merge-other-branch-in-current.sh
Last active April 4, 2023 05:36
Merge other branch into your current branch
#!/bin/bash
parent_branch="${1:-master}"
# Check if the current branch has any uncommitted changes
if [[ $(git status --porcelain) ]]; then
echo "Error: The current branch has uncommitted changes. Please commit or stash them before running this script."
exit 1
fi
@ssv445
ssv445 / git-format-php.sh
Created April 4, 2023 05:16
Only Format files which were changed by your branch/PR
#!/bin/bash
parent_branch="${1:-master}"
# Switch to the root directory of the Git repository
cd "$(git rev-parse --show-toplevel)"
# Check if there are any uncommitted changes
if [[ -n $(git status -s) ]]; then
echo "There are uncommitted changes in the branch. Please commit or stash them before running this script."
@ssv445
ssv445 / caddy.conf
Created July 1, 2022 04:08
Auto SSL for Tenant Domains for a SaaS Service
# for checking if it belongs ot our domain list
{
email [email protected]
on_demand_tls {
ask https://api.example.test/check-domain
interval 2m
burst 5
}
}
@ssv445
ssv445 / vue-index.html
Created January 5, 2022 06:48
Showing loading counter in Vue App, while Vue App is not loaded. Also show reload app buttong after few seconds, and force autoload the page after 60 seconds.
<script>
let notLoadedFor = 1;
let loadingElementId = 'loading-counter';
function reloadVueApp() {
var path = window.location.href + "?reset=true&ver=" + Math.random().toString(36).substring(2);
window.location.href = path;
};
const interval = setInterval(function() {
let el = document.getElementById(loadingElementId);