Skip to content

Instantly share code, notes, and snippets.

@ravisiyer
ravisiyer / ListNmnx.ps1
Created June 9, 2024 17:34
Powershell script that lists node_modules and .next folders in a folder/directory. It ignores subfolders within the node_modules or .next folders it finds.
# Lists folders/directories with names matching $ListFolders array elements (currently: node_modules and .next),
# in a user specified folder/directory or current directory. It also provides a total count of the folders it lists.
# It ignores subfolders within the matching $ListFolders array elements (node_modules and .next) it finds.
# It also ignores folders present in $ExcludeFolders array (currently: .git).
# Usage: script-name [optional-path]
#
# The script uses Get-ChildItem calling it recursively.
#
# Adapted from Getting files and folders recursively in PowerShell…without using -Recurse!,
# https://cloudrun.co.uk/powershell/getting-files-and-folders-recursively-in-powershell-without-using-recurse/
@ravisiyer
ravisiyer / CopyWoNmnx.ps1
Created June 9, 2024 16:33
Powershell script that copies contents of a folder/directory excluding node_modules and .next folders. It uses robocopy command to do the main work.
# Copies contents of a folder/directory excluding node_modules and .next folders.
# It uses robocopy command to do the main work.
# Usage: script-name Source-Folder-Name
# Output folder name is generated by concatenating script defined suffix (currently: -wo-nmnx) to
# Source-Folder-Name. The script checks if file/folder of this generated name exists and if so
# gives a suitable error message and then aborts.
# The script also strips trailing backslash from Source-Folder-Name if present before generating
# output folder name. Note that Powershell adds trailing backslash by default to folder names when
# tab is used to step through files and folders being specified in a command on console.
#
@ravisiyer
ravisiyer / ExcludeDirsRecurseListFilesDirs.ps1
Created May 5, 2024 14:43
Recursively outputs Get-ChildItem returned object for files and directories but excludes folders present in $ExcludeFolders variable in script
# Recursively outputs Get-ChildItem returned object for files and directories of current working directory
# OR user specified directory but excludes folders and their contents present in $ExcludeFolders variable
# in script
#
# Usage: script-name [optional-path] | next-cmd
# Usage Examples:
# Lists last modified time followed by full path for each folder & file in current directory
# excluding folders whose names are in $ExcludeFolders and such folders' contents
# script-name | ForEach-Object {"$($_.LastWriteTime) $($_.FullName)"}
#
@ravisiyer
ravisiyer / RecurseListFilesDirs-WO.ps1
Last active May 5, 2024 16:05
PowerShell scripts to recursively list files and directories without using -Recurse parameter for Get-ChildItem
# Recursively lists full path of files and directories of current working directory OR user specified directory
# using write-output.
#
# Usage: script-name [optional-path]
#
# Adapted from Getting files and folders recursively in PowerShell…without using -Recurse!,
# https://cloudrun.co.uk/powershell/getting-files-and-folders-recursively-in-powershell-without-using-recurse/
Param ($path = $pwd)
@ravisiyer
ravisiyer / h2linksameline.html
Created April 15, 2024 10:40
CSS: Putting H2 on left and link on right of same line
<!DOCTYPE html>
<html>
<head>
<title>H2 and link same line</title>
<style>
div {
background: #dbdbdb;
display: flex;
justify-content: space-between;
align-items: center;
@ravisiyer
ravisiyer / set-clearTimeout.html
Created April 15, 2024 09:56
JavaScript: setTimeout does NOT require a clearTimeout unless you want to cancel it before it fires (once)
<!-- Ref: https://developer.mozilla.org/en-US/docs/Web/API/setTimeout#examples -->
<button onclick="delayedMessage();">Show a message after two seconds</button>
<button onclick="clearMessage();">Cancel message before it happens</button>
<div id="output"></div>
<script>
let timeoutID;
function setOutput(outputContent) {
console.log("setOutput() called");
@ravisiyer
ravisiyer / bb.html
Created April 15, 2024 09:47
JavaScript: Opening window in new tab and changing its document contents
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body onload="afterLoad()">
BB document
<script>
@ravisiyer
ravisiyer / index.html
Last active April 11, 2024 06:44
Image resize test
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Image Resize Test</title>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<main>
@ravisiyer
ravisiyer / BlogInfoByUrl.html
Created April 1, 2024 14:16
Simple Samples/Tests for Blogger API Version 3 (v3.0) used from HTML & JavaScript
<html>
<head>
<title>Blogger API Example: Get blog info. by URL</title>
</head>
<body>
<div id="content"></div>
<script>
function handleResponse(response) {
console.log(response);
if (!response.kind || response.kind != "blogger#blog") {
@ravisiyer
ravisiyer / app.js
Created March 30, 2024 09:48
Barebones blogger blog feed to set of posts (book) using JavaScript and bypassing CORS by using a Node Express proxy server
const express = require("express");
const cors = require("cors");
const { createProxyMiddleware } = require("http-proxy-middleware");
const app = express();
app.use(cors());
app.use(
"/",
createProxyMiddleware({
target: "https://sathyasaiwithstudents.blogspot.com",