Skip to content

Instantly share code, notes, and snippets.

View saadmanrafat's full-sized avatar
🎯
Focusing

Saadman Rafat saadmanrafat

🎯
Focusing
View GitHub Profile
#!/bin/bash
echo -e "Fixing dpkg Error Code"
echo -e "Looking Into dpkg Info"
sudo mv /var/lib/dpkg/info /var/lib/dpkg/info_silent
echo -e "Creating Directory"
sudo mkdir /var/lib/dpkg/info
echo -e "Updating System"
sudo apt-get update -y
echo -e "Checking Dependencies & Installing"
RewriteEngine on
RewriteCond %{HTTP_HOST} ^olddomain.me [NC,OR]
RewriteCond %{HTTP_HOST} ^blog.olddomain.me [NC]
RewriteRule ^(.*)$ https://newdomain.com/$1 [L,R=301,NC]
keys:
consumer_key: CONSUMER_KEY
consumer_secret: CONSUMER_SECRET
access_token: ACCESS_TOKEN
access_token_secret: ACCESS_TOKEN_SECRET
bearer_token: BEARER_TOKEN
class TestRecentSearch(unittest.TestCase):
class Search(RecentSearch):
query = ['python']
max_results = ['10']
tweet_fields = ['created_at', 'lang', 'conversation_id']
def setUp(self) -> None:
self.search = self.Search()
for x in self.search.connect():
Launching pytest with arguments test_stream.py::TestRecentSearch in /home/saadman/twitter-stream.py/tests
============================= test session starts ==============================
platform linux -- Python 3.8.5, pytest-6.1.2, py-1.9.0, pluggy-0.13.1 -- /home/saadman/twitter-stream.py/env/bin/python
cachedir: .pytest_cache
rootdir: /home/saadman/twitter-stream.py
collecting ... collected 1 item
test_stream.py::TestRecentSearch::test_result_count
@saadmanrafat
saadmanrafat / detect_documents.py
Created November 6, 2020 07:52
Cloud Vision API: Detect Documents
import json
import requests
from pprint import pprint
def detect_document(path: str) -> str:
"""Makes manual Http request to the https://vision.googleapis.com/v1/files:annotate
WAITING
?
PLEASE
TURN
OFF
YOUR
ENGINE
from google.cloud import vision
if __name__ == '__main__':
client = vision.ImageAnnotatorClient()
response = client.annotate_image({
'image': {'source': {'image_uri': 'https://bit.ly/3mXXjy0'}},
'features': [{'type_': vision.Feature.Type.DOCUMENT_TEXT_DETECTION}]
})
for words in response.text_annotations[1:]:
print(words.description)
~$ mkdir object-recognition
~$ cd object-recognition
~$ virtualenv --python=python3.8 venv
~$ pip3 install google-cloud-vision==2.0.0
import io
import argparse
from google.cloud.vision_v1 import ImageAnnotatorClient, Image
from colorama import init, Fore
def cli() -> None:
init()
parser = argparse.ArgumentParser()