Skip to content

Instantly share code, notes, and snippets.

View bhumit070's full-sized avatar

Bhoomit Ganatra bhumit070

  • India
  • 11:28 (UTC +05:30)
View GitHub Profile
@bhumit070
bhumit070 / shell_script_loops.md
Created August 1, 2024 06:14
All loops example in shell script
  • continue: Skips the rest of the current loop iteration and proceeds with the next iteration.
  • break: Exits the loop immediately.

Here are examples demonstrating the use of continue and break in each type of loop:

Using for loop:

#!/bin/bash

for file in "$PWD"/*
@bhumit070
bhumit070 / script.md
Created July 31, 2024 11:04
Shell script operator uses

String Comparisons:

-n STRING:

#!/bin/bash

my_string="hello"

if [ -n "$my_string" ]; then
  echo "The string is not empty."
else
@bhumit070
bhumit070 / replace_space_with_dots.sh
Created April 26, 2024 11:53
Replace space with dots
for file in *; do
# Check if the file name contains spaces
if [[ "$file" == *" "* ]]; then
# Replace spaces with dots and rename the file
new_name=$(echo "$file" | tr ' ' '.')
mv "$file" "$new_name"
echo "Renamed '$file' to '$new_name'"
fi
done
@bhumit070
bhumit070 / launch.json
Created July 24, 2023 16:11
VsCode Launch.json for VsCode Debugger ( JavaScript )
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Node",
"port": 9229,
"request": "attach",
@bhumit070
bhumit070 / express_zod_validator.ts
Created May 12, 2023 15:58
Way to parse body, params, and query in Nodejs using Zod
import express, { Request, Response } from 'express';
import z, { AnyZodObject, ZodError } from 'zod';
import { generateError } from 'zod-error';
const app = express();
const mySchema = z.object({
body: z.object({
name: z.string(),
}),
@bhumit070
bhumit070 / macos_screen_shot_script.sh
Last active May 14, 2023 13:10
macos_screen_shot_script.sh
#!/bin/bash
randomScreenShotName="$RANDOM.png"
screenShotPath="/tmp/$randomScreenShotName"
screencapture $screenShotPath
screenShotDir="$HOME/screenshots/$(date +"%Y-%m-%d")"
if ! [ -d $screenShotDir ]; then
mkdir -p $screenShotDir
@bhumit070
bhumit070 / stop_on_debug.html
Created May 3, 2023 04:09
STOP_BROWSER_ON_DEBUGGER_IF_DEVTOOLS_IS_OPENED
-- HTML
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
</head>
<body>
@bhumit070
bhumit070 / typesafe_localstorage.ts
Created April 22, 2023 17:21
Typesafe Localstorage With Typescript And Zod
import * as z from 'zod';
const LocalStorageSchema = z.object({
name: z.string(),
age: z.number(),
isEmployed: z.boolean(),
});
type LocalStorageData = z.infer<typeof LocalStorageSchema>;
@bhumit070
bhumit070 / image.html
Last active April 22, 2023 05:37
Google image 403 error
<img
referrerpolicy="no-referrer"
src="link-to-image"
/>
@bhumit070
bhumit070 / nodejs_debug_vscode.json
Created April 21, 2023 17:43
Vscode NodejS Debugger
{
"version": "0.2.0",
"configurations": [
{
"name": "Attach to Node",
"port": 9229,
"request": "attach",
"skipFiles": ["<node_internals>/**"],
"envFile": "${workspaceFolder}/.env",
"type": "node"