Skip to content

Instantly share code, notes, and snippets.

View bhuiyanmobasshir94's full-sized avatar
🎖️
Focused on achievement

Mobasshir Bhuiya bhuiyanmobasshir94

🎖️
Focused on achievement
View GitHub Profile
@bhuiyanmobasshir94
bhuiyanmobasshir94 / print_cpu_usage.py
Last active April 28, 2023 02:40 — forked from rkaneko/print_cpu_usage.py
Profile CPU usage in Python using psutil.
import time
import multiprocessing as mp
import psutil
from typing import Any, Callable, List, Tuple
def monitor(target: Callable[..., Any], args: Tuple[Any, ...]) -> List[float]:
worker_process = mp.Process(target=target, args=args)
worker_process.start()
p = psutil.Process(worker_process.pid)
@bhuiyanmobasshir94
bhuiyanmobasshir94 / text2png.py
Created September 3, 2022 07:30 — forked from destan/text2png.py
Python text to image (png) conversion with automatic new line calculation
# coding=utf8
import PIL
from PIL import ImageFont
from PIL import Image
from PIL import ImageDraw
def text2png(text, fullpath, color = "#000", bgcolor = "#FFF", fontfullpath = None, fontsize = 13, leftpadding = 3, rightpadding = 3, width = 200):
REPLACEMENT_CHARACTER = u'\uFFFD'
NEWLINE_REPLACEMENT_STRING = ' ' + REPLACEMENT_CHARACTER + ' '
@bhuiyanmobasshir94
bhuiyanmobasshir94 / docker-help.md
Created June 4, 2019 03:00 — forked from bradtraversy/docker-help.md
Docker Commands, Help & Tips

Docker Commands, Help & Tips

Show commands & management commands

$ docker

Docker version info

@bhuiyanmobasshir94
bhuiyanmobasshir94 / README.md
Created March 2, 2019 07:24 — forked from hofmannsven/README.md
My simply Git Cheatsheet
@bhuiyanmobasshir94
bhuiyanmobasshir94 / tweet_listener.py
Created February 13, 2019 18:12 — forked from hugobowne/tweet_listener.py
Here I define a Tweet listener that creates a file called 'tweets.txt', collects streaming tweets as .jsons and writes them to the file 'tweets.txt'; once 100 tweets have been streamed, the listener closes the file and stops listening.
class MyStreamListener(tweepy.StreamListener):
def __init__(self, api=None):
super(MyStreamListener, self).__init__()
self.num_tweets = 0
self.file = open("tweets.txt", "w")
def on_status(self, status):
tweet = status._json
self.file.write( json.dumps(tweet) + '\n' )
self.num_tweets += 1
@bhuiyanmobasshir94
bhuiyanmobasshir94 / cull.py
Created December 13, 2018 19:00 — forked from jsundram/cull.py
Check if lat long is inside the bounds of the continental US (box model, not shape)
# http://en.wikipedia.org/wiki/Extreme_points_of_the_United_States#Westernmost
top = 49.3457868 # north lat
left = -124.7844079 # west long
right = -66.9513812 # east long
bottom = 24.7433195 # south lat
def cull(l):
c = []
for (lat, lng) in l:
if bottom <= lat <= top and left <= lng <= right: