Skip to content

Instantly share code, notes, and snippets.

View AksAman's full-sized avatar
👨‍💻

Aman Kumar AksAman

👨‍💻
View GitHub Profile
@AksAman
AksAman / generate_secret_key.sh
Created December 7, 2022 19:35
Generate Django secret key
# Run in your shell (with virtual environment active)
python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
@AksAman
AksAman / failsafe.sh
Created November 30, 2022 21:22
fail/exit bash/shell script execution if last command fails
# Method 1
echo "Running command"
my_command # use your command here
if [ $? -ne 0 ]; then { echo "Failed, aborting." ; exit 1; } fi
# Method 2 (Same as method 1, but with else block)
my_command # use your command here
if [ $? -eq 0 ]
then
@AksAman
AksAman / remove-migrations.sh
Created November 26, 2022 20:50
remove django migration files snippet
find . -path "*/migrations/*.py" -not -name "__init__.py" -not -path "./*env/*"
@AksAman
AksAman / settings.json
Created November 23, 2022 22:05
python .vscode settings.json
{
"python.defaultInterpreterPath": "venv/bin/python",
"python.linting.pylintEnabled": false,
"python.linting.flake8Enabled": true,
"python.linting.enabled": true,
"python.linting.flake8Args": [
"--max-line-length=120",
"--ignore=E501, E402, E731, W503, W504"
],
"python.linting.pylintArgs": [
@AksAman
AksAman / bookmarks.html
Created November 6, 2022 23:01
Netflix codes bookmark file
<!-- based on codes provided on https://www.netflix-codes.com/ -->
<!-- DO NOT USE ANY AUTO FORMATTING OR THE BOOKMARK FILE WON'T WORK -->
<DL>
<H3>Netflix Codes</H3>
<DL>
<H3>Action &amp; adventure</H3>
<DL>
<A HREF="https://www.netflix.com/browse/genre/1365" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABtUlEQVQ4jYWTTWtTYRCFnzP3JmkTkmCRVnHlRsG/4E5w5broj9H/oxbciChUcOVeXVTciWCjlqC2NL2Se+e4SIXmo/Xshpd5OO+ZGQCeQgGwVw4e/upseNTZyK/tSx/3oQvwvDV4/bI19G576Ffl4NHZngDYYaYvmapsGjztoBsue7cB5AwAzJICYPu0OAk8timtphRRqPVg9iKMQecAzhQ6sJnaRWU7iXuGtQYqWeBlC3OAdeDIySFWiqYrtn4W/bu/7ZNCXmlh0QFI7DtVGCS5ifL+caYaW14RwhygJugIvmW6gpg4sXQH4tYEHOeF+E9J0jJMsH5kgrDxlQ3p5qFdF/rvFwIk2pI/Z0YYWfh6RFa2sMmLAABp00fl2P4kNLLRVgQ9yVNBLCCWAI2gJ8nknu03XQVrkFsK/TGUCy1LACEK4V6EI+sntpUS1xS2DXmBA5E2pjHqS+uXm6Pdifkuuxgi9xWcxPwsF6YQSLJFltARVEG+WEOUUr0pucrZNu2sAohU2GpZIegANJ4+Rsiiu6nQ4PSktlcBErI24yQ/yH4HMKqP39YNz1rp9wUeX4352P4CWRLiC+ie/GoAAAAASUVORK5CYII">** Action &amp; adventure **</A>
<A HREF="https://www.netflix.
@AksAman
AksAman / colored_logger.py
Created October 22, 2022 10:31
Python logger with colors
"""
To use, install termcolor using pip:
$ python -m pip install termcolor
copy and paste the following in your code
# region Logging
import logging
from colored_logger import get_logger
fname = Path(__file__).stem
@AksAman
AksAman / colored_console.py
Created October 20, 2022 22:28
Console Colors
class ColorConsole:
HEADER = "\033[95m"
OKBLUE = "\033[94m"
OKCYAN = "\033[96m"
OKGREEN = "\033[92m"
WARNING = "\033[93m"
FAIL = "\033[91m"
ENDC = "\033[0m"
BOLD = "\033[1m"
UNDERLINE = "\033[4m"
@AksAman
AksAman / touch2.sh
Created October 7, 2022 04:38
Alias for creating folders and final file recursively (like `mkdir -p` but for files)
touch2() { mkdir -p "$(dirname "$1")" && touch "$1" ; }
@AksAman
AksAman / lazygit.sh
Last active October 7, 2022 04:38
Alias to quickly add, commit and push to git
lazygit() {
git add .
git commit -a -m "$1"
git push
}
@AksAman
AksAman / gzf-git-log.sh
Last active May 24, 2023 23:29
Alias to view git log in a pretty way with fuzzy search and files preview using fzf
# fzf from https://github.com/junegunn/fzf
# diff-so-fancy from https://github.com/so-fancy/diff-so-fancy
gcop() {
git log \
--reverse \
--color=always \
--format="%C(cyan)%h %C(blue)%ar%C(auto)%d% C(yellow)%s%+b %C(magenta)%ae" "$@" |
fzf -i -e +s \
--reverse \