Skip to content

Instantly share code, notes, and snippets.

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.

@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' \
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@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
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.katex=e():t.katex=e()}("undefined"!=typeof self?self:this,function(){return function(t){var e={};function r(a){if(e[a])return e[a].exports;var n=e[a]={i:a,l:!1,exports:{}};return t[a].call(n.exports,n,n.exports,r),n.l=!0,n.exports}return r.m=t,r.c=e,r.d=function(t,e,a){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:a})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var a=Object.create(null);if(r.r(a),Object.defineProperty(a,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var n in t)r.d(a,n,function(e){return t[e]}.bind(null,n));return a},r.n=function(t){var e=t&&t.__esModule?function(){return t.d
var chemParse=function(t,e){for(var r="",a=t[t.length-1].loc.start,n=t.length-1;0<=n;n--)t[n].loc.start>a&&(r+=" ",a=t[n].loc.start),r+=t[n].text,a+=t[n].text.length;return texify.go(mhchemParser.go(r,e))},mhchemParser={go:function(t,e){if(!t)return[];void 0===e&&(e="ce");var r,a="0",n={parenthesisLevel:0};t=(t=(t=t.replace(/\n/g," ")).replace(/[\u2212\u2013\u2014\u2010]/g,"-")).replace(/[\u2026]/g,"...");for(var o=10,c=[];;){r!==t?(o=10,r=t):o--;var i=mhchemParser.stateMachines[e],s=i.transitions[a]||i.transitions["*"];t:for(var p=0;p<s.length;p++){var u=mhchemParser.patterns.match_(s[p].pattern,t);if(u){for(var m,h=s[p].task,_=0;_<h.action_.length;_++){if(i.actions[h.action_[_].type_])m=i.actions[h.action_[_].type_](n,u.match_,h.action_[_].option);else{if(!mhchemParser.actions[h.action_[_].type_])throw["MhchemBugA","mhchem bug A. Please report. ("+h.action_[_].type_+")"];m=mhchemParser.actions[h.action_[_].type_](n,u.match_,h.action_[_].option)}mhchemParser.concatArray(c,m)}if(a=h.nextState||a,!(0<t.length)
@tejasvi
tejasvi / solarized_light.theme
Created June 28, 2020 05:28
Solarized light for Windows 10
; Copyleft (ɔ) github/tejasvi
[Theme]
; High Contrast White - IDS_THEME_DISPLAYNAME_HCWHITE
DisplayName=Solarized Light
ThemeId={E8520960-0633-4E7A-837D-FR2004778FE2}
; Computer - SHIDI_SERVER
[CLSID\{20D04FE0-3AEA-1069-A2D8-08002B30309D}\DefaultIcon]
DefaultValue=%SystemRoot%\System32\imageres.dll,-109
@tejasvi
tejasvi / install.sh
Created June 19, 2020 22:32
Install Trilium server on Termux
pkg install nodejs python build-essential --no-install-recommends -y
wget https://github.com/zadam/trilium/archive/stable.zip`
unzip stable.zip
cd trilium-stable
mv package-lock.json package-lock.json.bak
sed -i.bak '/electron/d' package.json
npm install [email protected] --ignore-scripts
npm install
node src/www
@tejasvi
tejasvi / dest
Created April 1, 2020 07:08
Coordinates
'{"lat":{"0":49.737890938,"1":48.893762683,"2":49.6272062817,"3":48.1299256123,"4":49.517221979,"5":50.3944193027,"6":47.4845670104,"7":49.7189273061,"8":49.2617919998,"9":48.4041846676,"10":47.5750117106,"11":48.0367318424,"12":49.458327926,"13":48.3970228385,"14":47.9939529041,"15":49.8395180655,"16":49.0378845278,"17":48.1788356336,"18":48.9109193134,"19":48.0500080347,"20":49.9690773632,"21":48.2402721951,"22":49.2923634301,"23":49.3640773318,"24":49.5761394404,"25":49.7331346294,"26":49.0344437457,"27":49.8266293588,"28":48.3084366594,"29":48.3457915293,"30":48.0773187047,"31":48.8918404657,"32":48.0649622632,"33":48.8371803466,"34":49.7194167745,"35":48.9629851712,"36":49.8855583011,"37":48.4305947898,"38":48.7074828169,"39":48.3853556159,"40":49.2369644567,"41":47.8753410163,"42":48.5928472172,"43":47.5953129534,"44":48.8810690971,"45":48.4032897118,"46":48.4058677994,"47":49.7620049469,"48":48.771944142,"49":49.4783016491,"50":48.5025019412,"51":48.6955310894,"52":49.5637232484,"53":49.2471789894,"54"
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCkkwZ69HwTep+LDSpU5VbVMK/z1aJMoFjdrZSxLN02K1xVajRmGOY+jZgBHX8mrqEJHS0VXZsZd2V1v0A74z9DEN6vzTiadQmEXQbqVGy7szOlFFxXwBDmqo4l0nl9F9q9De5BVMjsZXI+iXJxTaRD8kkrhMrrZ3i/PenLsv2r4b/zWuoIkD49UuRQXtb9EAC2PgVrH3uy48qiStws/UST/J+lRY+4QdeFlgGP1kqWSYsPHm8SrZsctF0H+sHo6KaTfZNzZFhQ3btKc1xUZ5SVwE8+A/TjPYTuMhwFj7OlQDoNppM4CkokUt3JiZZj+h59/c+sSpHGPbHz+r8gCBKZ u@pc