Skip to content

Instantly share code, notes, and snippets.

View sumitsahoo's full-sized avatar
👨‍💻
Architecting…

Sumit Sahoo sumitsahoo

👨‍💻
Architecting…
View GitHub Profile
@sumitsahoo
sumitsahoo / kill_transaction.sql
Created February 7, 2025 05:30
Kill a db transaction in PostgreSQL
-- Find in progress transactions
SELECT *
FROM pg_stat_activity
WHERE state = 'idle in transaction'
AND pid <> pg_backend_pid()
AND query LIKE '%<table_name>%';
-- Kill process
@sumitsahoo
sumitsahoo / react_https_guide_macos.md
Last active October 14, 2024 14:15
Run react app as HTTPS localhost

Make sure openssl is installed

brew install openssl

Generate cert and key

openssl req -x509 -newkey rsa:4096 -keyout cert.key -out cert.crt -sha256 -days 3650 -nodes -subj "/C=XX/ST=YOUR_STATE/L=YOUR_LOCATION/O=YOUR_COMPANY/OU=YOUR_ORG/CN=YOUR_DOMAIN"
@sumitsahoo
sumitsahoo / create_macos_usb.sh
Last active October 30, 2024 08:10
Create bootable macOS USB drive
# Change macOS image name and USB drive name
# USB formatted as Mac OS Extended (Journaled) and choose GUID Partition Map as the Scheme.
sudo /Applications/Install\ macOS\ Sequoia.app/Contents/Resources/createinstallmedia --volume /Volumes/Sequoia
# Press and hold power button for boot menu (Apple Silicon)
@sumitsahoo
sumitsahoo / load_env.sh
Created March 29, 2024 14:50
Load .env variables in zsh
set -a; source .env; set +a
@sumitsahoo
sumitsahoo / set_git_user.sh
Last active July 15, 2024 09:10
Set local git user name and email
git config --local user.name "Sumit Sahoo"
git config --local user.email "[email protected]"
@sumitsahoo
sumitsahoo / settings.json
Created May 28, 2023 15:23
Set VS Code terminal font
"terminal.integrated.fontSize": 13,
"terminal.integrated.fontFamily": "'MesloLGS NF','JetBrains Mono', Menlo, Monaco, 'Courier New', monospace",
@sumitsahoo
sumitsahoo / remove_dock_delay.sh
Last active May 19, 2023 17:49
Remove dock delay in macOS
# Remove delay
defaults write com.apple.dock autohide -bool true && defaults write com.apple.dock autohide-delay -float 0 && defaults write com.apple.dock autohide-time-modifier -float 0 && killall Dock
# Faster animation
# defaults write com.apple.dock autohide -bool true && defaults write com.apple.dock autohide-delay -float 0 && defaults write com.apple.dock autohide-time-modifier -float 0.65 && killall Dock
# Revert back
# defaults delete com.apple.dock autohide && defaults delete com.apple.dock autohide-delay && defaults delete com.apple.dock autohide-time-modifier && killall Dock
@sumitsahoo
sumitsahoo / delete_android_studio.sh
Last active July 28, 2021 17:12
Delete Android Studio (Mac)
# Deletes the Android Studio application
# Note that this may be different depending on what you named the application as, or whether you downloaded the preview version
rm -Rf /Applications/Android\ Studio.app
# Delete All Android Studio related preferences
# The asterisk here should target all folders/files beginning with the string before it
rm -Rf ~/Library/Preferences/AndroidStudio*
rm -Rf ~/Library/Preferences/Google/AndroidStudio*
# Deletes the Android Studio's plist file
rm -Rf ~/Library/Preferences/com.google.android.*
# Deletes the Android Emulator's plist file
@sumitsahoo
sumitsahoo / add_permission.sh
Last active October 23, 2020 11:49
Fix brew permission from another account in macOS
# First create a user group and add users who are going to use shared brew
# User group : brew-usergroup
echo $(brew --prefix)
echo $(groups $(whoami))
sudo dseditgroup -o edit -a $(whoami) -t user brew-usergroup
sudo chgrp -R brew-usergroup $(brew --prefix)/*
sudo chmod -R g+rwX $(brew --prefix)/*
ls -lah $(brew --prefix)
@sumitsahoo
sumitsahoo / JsonValidator.java
Created July 29, 2020 07:42
Check if a string is a valid JSON
private static boolean isJson(String Json) {
try {
new JSONObject(Json);
} catch (JSONException ex) {
try {
new JSONArray(Json);
} catch (JSONException ex1) {
return false;
}
}