Skip to content

Instantly share code, notes, and snippets.

View bhumit070's full-sized avatar

Bhoomit Ganatra bhumit070

  • India
  • 07:14 (UTC +05:30)
View GitHub Profile
@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"
#!/bin/bash
function ss() {
local screenName="$1"
if [ -z "$screenName" ]; then
echo "No service name provided."
exit 1
fi
local isScreenRunning=$(screen -ls | grep -ciw "$screenName")
@bhumit070
bhumit070 / event_emitter.ts
Created April 15, 2023 05:10
Type safe event emitter
type Listener<Args extends Array<any>> = (...args: Args) => void;
class MyEmitter<EventMap extends Record<string, Array<any>>> {
private eventListeners: {
[K in keyof EventMap]?: Set<Listener<EventMap[K]>>;
} = {};
constructor() {}
on<K extends keyof EventMap>(
@bhumit070
bhumit070 / nested_object_key.ts
Created April 9, 2023 10:48
nested object keys type
const locale = {
'en_us': {
hello: 'hello',
greetings: {
morning: 'Good Morning',
evening: 'Good Evening',
else: {
foo: 'bar'
}
},
@bhumit070
bhumit070 / remove_node_modules.sh
Last active April 21, 2023 06:14
Delete All node_modules in directory
find . -name "node_modules" -type d -prune | xargs du -chs # to check how much space node_modules is taking
find . -name "node_modules" -type d -prune | xargs rm -rf # to remove node_modules
@bhumit070
bhumit070 / Podfile
Last active April 21, 2023 06:14
Hermes Engine Fix While Pod Install
installer.aggregate_targets.each do |aggregate_target|
aggregate_target.user_project.native_targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['LIBRARY_SEARCH_PATHS'] = ['$(SDKROOT)/usr/lib/swift', '$(inherited)']
end
end
aggregate_target.user_project.save
end
@bhumit070
bhumit070 / settings.json
Last active April 21, 2023 06:15
vscode-settings.json
{
// Editor Related Settings
"editor.wordWrap": "off",
"editor.cursorStyle": "line",
"editor.lineNumbers": "relative",
"editor.autoClosingQuotes": "always",
"editor.suggestSelection": "first",
"editor.autoClosingBrackets": "always",
"editor.autoSurround": "languageDefined",
"editor.defaultFormatter": "dbaeumer.vscode-eslint",
@bhumit070
bhumit070 / bst.js
Created April 8, 2022 08:53
BST add and delete
class Node {
constructor(value) {
this.value = value
this.left = null
this.right = null
}
}
class Tree {
constructor() {