Skip to content

Instantly share code, notes, and snippets.

@tejasvi
tejasvi / error
Created February 7, 2021 19:22
konsh vi mode error with async prompt
Traceback (most recent call last):
File "/home/u/miniconda3/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 22429, in main
sys.exit(main_xonsh(args))
File "/home/u/miniconda3/lib/python3.9/site-packages/xonsh/__amalgam__.py", line 22467, in main_xonsh
shell.shell.cmdloop()
File "/home/u/miniconda3/lib/python3.9/site-packages/xonsh/ptk_shell/shell.py", line 338, in cmdloop
line = self.singleline(auto_suggest=auto_suggest)
File "/home/u/miniconda3/lib/python3.9/site-packages/xonsh/ptk_shell/shell.py", line 307, in singleline
line = self.prompter.prompt(**prompt_args)
File "/home/u/miniconda3/lib/python3.9/site-packages/prompt_toolkit/shortcuts/prompt.py", line 1013, in prompt
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@tejasvi
tejasvi / leetcode_question_downloader.py
Created October 28, 2021 12:39
Download leetcode questions. On retrying, only downloads the missing ones.
"""Download leetcode questions in leetcode_questions.json. On retrying, only download the missing ones."""
from time import sleep
from threading import Thread
from pathlib import Path
from subprocess import check_output
from json import loads, dump
response = loads(check_output("""curl 'https://leetcode.com/graphql/' \
-H 'content-type: application/json' \

A password is considered strong if the below conditions are all met:

  • It has at least 6 characters and at most 20 characters.
  • It contains at least one lowercase letter, at least one uppercase letter, and at least one digit.
  • It does not contain three repeating characters in a row (i.e., "...aaa..." is weak, but "...aa...a..." is strong, assuming other conditions are met).

Given a string password, return the minimum number of steps required to make password strong. if password is already strong, return 0.