Skip to content

Instantly share code, notes, and snippets.

View asadamatic's full-sized avatar
🎯
Focusing

ASAD HAMEED asadamatic

🎯
Focusing
  • Islamabad, Pakistan
  • 15:06 (UTC +05:00)
View GitHub Profile
@asadamatic
asadamatic / downloadImage.py
Created March 5, 2020 05:05
Code to donwload images using requests library in python.
import requests
import time
imageUrl = 'https://images.unsplash.com/photo-1558981396-5fcf84bdf14d'
image = requests.get(imageUrl)
imageBytes = image.content
fileName = imageUrl.split('/')[3] + '.png' #getting photo name from the url
@asadamatic
asadamatic / si_to_int.py
Last active February 16, 2020 07:51 — forked from gajeshbhat/strToInt.py
Convert k to Integer thousand Python.
def convert_si_to_number(x):
total_stars = 0
if 'k' in x:
if len(x) > 1:
total_stars = float(x.replace('k', '')) * 1000 # convert k to a thousand
elif 'M' in x:
if len(x) > 1:
total_stars = float(x.replace('M', '')) * 1000000 # convert M to a million
elif 'B' in x:
total_stars = float(x.replace('B', '')) * 1000000000 # convert B to a Billion