Skip to content

Instantly share code, notes, and snippets.

View HarshCasper's full-sized avatar
🎯
Who Dares Wins!

Harsh Mishra HarshCasper

🎯
Who Dares Wins!
View GitHub Profile
{
"LabApp": { "collaborative": true, "expose_app_in_browser": true }
}
@HarshCasper
HarshCasper / Every possible TypeScript type.md
Created September 25, 2021 04:36 — forked from laughinghan/Every possible TypeScript type.md
Diagram of every possible TypeScript type

Hasse diagram of every possible TypeScript type

  • any: magic, ill-behaved type that acts like a combination of never (the proper [bottom type]) and unknown (the proper [top type])
    • Anything except never is assignable to any, and any is assignable to anything at all.
    • Identities: any & AnyTypeExpression = any, any | AnyTypeExpression = any
    • Key TypeScript feature that allows for [gradual typing].
  • unknown: proper, well-behaved [top type]
    • Anything at all is assignable to unknown. unknown is only assignable to itself (unknown) and any.
    • Identities: unknown & AnyTypeExpression = AnyTypeExpression, unknown | AnyTypeExpression = unknown
  • Prefer over any whenever possible. Anywhere in well-typed code you're tempted to use any, you probably want unknown.
import os
folder = r'Project Path'
for filename in os.listdir(folder):
infilename = os.path.join(folder, filename)
if not os.path.isfile(infilename): continue
oldbase = os.path.splitext(filename)
newname = infilename.replace('.txt', '.js')
output = os.rename(infilename, newname)
print("Complete")
if __name__ == '__main__':
app.run()
@app.errorhandler(404)
@app.route('/<lol>')
def not_found(lol):
return "<h1git >Are You Lost?<h1>"
@app.route('/givetext/<sub>/<int:count>')
def text_count_meme(sub,count):
if count >= 50:
return jsonify({
'status_code': 400,
'message': 'Please ensure the count is less than 50'
})
requested = get_text(sub, 100)
random.shuffle(requested)
@app.route('/givetext/<sub>')
def text_meme(sub): #showerthoughts or quotes
r = get_text(sub,100)
requsted = random.choice(r)
return jsonify({
'Title': requsted["Title"],
'Selftext': requsted["text"],
'Upvotes': requsted["Upvotes"],
'Downvotes': requsted["Downvotes"],
@app.route('/givememe/<sub>/<int:c>')
def multiple_from_sub(sub, c):
if c >= 50:
return jsonify({
'status_code': 400,
'message': 'Ensure that the Count is less than 50'
})
@app.route('/givememe/<int:c>')
def multiple(c):
sub = random.choice(randommeme)
if c >= 50:
return jsonify({
'status_code': 400,
'message': 'Ensure that the Count is less than 50'
})
@app.route('/givememe/<sub>')
def custom_meme(sub):
try:
r = get_meme(sub,100)
except:
return jsonify({
'Status_code': 404,
'Message': 'Invalid Subreddit'
})