Skip to content

Instantly share code, notes, and snippets.

View shreewatsa's full-sized avatar

shreewatsa shreewatsa

  • kathmandu , nepal
  • 16:25 (UTC +05:45)
View GitHub Profile
@shreewatsa
shreewatsa / git_cheatsheet.md
Last active August 27, 2024 16:29
Git Cheatsheet

Edit global git config. Remove --global flag to edit project wise git configs:

git config --global --edit;

Git aliases

Global aliases are stored in file ~/.gitconfig
Create Git aliases:

git config --global alias.recent-branches "for-each-ref --sort=-committerdate refs/heads/ refs/remotes/ --format='%(committerdate:iso8601) %(refname:short)'";  # Usage: git recent-branches;
git config --global alias.stashsave '!f() { git stash push -m "$1"; }; f' # Usage: git stashsave "foo";
git config --global alias.aliases "config --get-regexp '^alias\.'"; git aliases;  # Usage: git aliases;
@shreewatsa
shreewatsa / alacritty_cheatsheet.md
Created February 23, 2023 08:46
Alacritty Cheatsheet

>Command + b : Search on the visible screen buffer.

@shreewatsa
shreewatsa / macos_cheatsheet.md
Last active February 14, 2025 12:11
MacOS Cheatsheet

Clear MAC password policies

# Run the following in your shell.
pwpolicy -clearaccountpolicies;
passwd;
security set-keychain-password;
@shreewatsa
shreewatsa / yabai_config.md
Created March 15, 2023 07:25
MacOS: Yabai Configuration File aka yabairc

Config File Location: ~/.config/yabai/yabairc

#!/usr/bin/env sh

yabai -m signal --add event=dock_did_restart action="sudo yabai --load-sa"
sudo yabai --load-sa


# global settings
yabai -m config mouse_follows_focus          off
@shreewatsa
shreewatsa / skhd_config.md
Last active March 15, 2023 07:44
MacOS: skhd configuration file aka skhdrc

skhd config file location: ~/.config/skhd/skhdrc

Thinking behind these shortcuts:
Use 'cmd' key for all desktop,window,space related shortcuts. Here, cmd+alt is preferred to cmd+shift.
Use 'alt' key for all tmux related shortcuts.
Use 'ctrl', and leader key 'space' for vim related shortcuts.

Note: Most of the following shortcuts are configured for yabai.

#!/usr/bin/env sh
@shreewatsa
shreewatsa / bash_strict_mode.md
Created March 15, 2023 08:18 — forked from vncsna/bash_strict_mode.md
set -e, -u, -o, -x pipefail explanation

set -e, -u, -o, -x pipefail

The set lines

  • These lines deliberately cause your script to fail. Wait, what? Believe me, this is a good thing.
  • With these settings, certain common errors will cause the script to immediately fail, explicitly and loudly. Otherwise, you can get hidden bugs that are discovered only when they blow up in production.
  • set -euxo pipefail is short for:
set -e
set -u
@shreewatsa
shreewatsa / README.md
Last active May 26, 2023 00:53
Competitive Programming Gist

Use the GNU version of gcc instead of the Clang version.

$ g++ --version;
$ brew install gcc;
$ cd /usr/local/bin; ls;
$ g++-13 --version;

Make alias to GNU version of gcc OR Create symlink.

$ echo 'alias gcc="/usr/local/bin/gcc-13"' >> ~/.zshrc;
$ echo 'alias g++="/usr/local/bin/g++-13"' >> ~/.zshrc;

@shreewatsa
shreewatsa / tools.md
Last active October 31, 2024 00:52
Install softwares in remote machine

Install fzf (fuzzy finder)

curl -O https://github.com/junegunn/fzf/releases/download/0.41.1/fzf-0.41.1-linux_amd64.tar.gz;
scp ./fzf* vm:/path/in/remote;
tar -xvzf fzf-0.41.1-linux_amd64.tar.gz;
mv ./fzf /usr/local/bin/;
@shreewatsa
shreewatsa / README.md
Last active August 27, 2024 16:35
How to profile python applications ?

Profiling Python applications.

  1. Profiling time (time complexity) : Scalene, Yappi, pprofile, Snakeviz, Pyinstrument, py-spy, etc.
  2. Profiling memory (space complexity) : memory_profiler, guppy/hpy, tracemalloc, Scalene, Pympler, etc.
@shreewatsa
shreewatsa / password_policy.md
Created July 13, 2023 08:08
Change password policy in linux

Change this file : /etc/pam.d/common-password

password    [success=1 default=ignore]  pam_unix.so minlen=1 sha512
password    requisite           pam_deny.so
password    required            pam_permit.so
password    optional    pam_gnome_keyring.so