Skip to content

Instantly share code, notes, and snippets.

View adamshamsudeen's full-sized avatar
🎯
Focusing

Adam Shamsudeen adamshamsudeen

🎯
Focusing
View GitHub Profile
import pyautogui
import time
#enable accssibilty permssion to terminal
#first get the position to click.
# pos = pyautogui.position()
# print(pos)
# x=1388, y=667
while True:
pyautogui.moveTo(1372, 670) # move mouse to the window
pyautogui.dragTo(1372, 670, button = 'left') # focus the window
import logging
logger = logging.getLogger('name')
logger.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
# create file handler which logs even debug messages
fh = logging.FileHandler('name.log')
fh.setLevel(logging.WARNING)
fh.setFormatter(formatter)
logger.addHandler(fh)
@adamshamsudeen
adamshamsudeen / creating ssh keys.txt
Created March 27, 2020 14:12
ssh keys generation
> on the local server do the following:
mkdir ~.ssh
chmod 750 ~
chmod 700 ~/.ssh
ssh-keygen -t rsa -b 2048
cat id_rsa_<server_name>.pub
> On the remote server do the following:
mkdir ~.ssh
chmod 750 ~
@adamshamsudeen
adamshamsudeen / redis-producer-consumer.py
Last active November 18, 2021 07:26 — forked from igniteflow/redis-producer-consumer.py
A very simple implementation of a Redis producer-consumer messaging queue in Python3
import redis
import time
import sys
def producer():
r = redis.Redis()
i = 0
while True:
r.rpush('queue', 'Message %d' % i)
@adamshamsudeen
adamshamsudeen / postgres
Last active December 9, 2019 15:24
postgress setup on ubuntu for django
sudo apt-get install libpq-dev postgresql postgresql-contrib
sudo -u postgres -i
psql
create database tagger;
create user tagger_user with password 'passsss';
grant all privileges on database tagger to tagger_user;
ALTER ROLE tagger_user SET client_encoding TO 'utf8';
ALTER ROLE tagger_user SET default_transaction_isolation TO 'read committed';
ALTER ROLE tagger_user SET timezone TO 'UTC';
@adamshamsudeen
adamshamsudeen / chardet.sh
Last active March 13, 2019 13:40
If chardet error raises uring doc_bot install
sudo apt install --reinstall python-debian python3-debian python-chardet python3-chardet
@adamshamsudeen
adamshamsudeen / main.py
Last active February 27, 2019 10:40
running flask app with all the gunicorn and logging
import logging
app = Flask(__name__)
# gunicorn_error_logger = logging.getLogger('gunicorn.error')
# app.logger.handlers.extend(gunicorn_error_logger.handlers)
# app.logger.setLevel(logging.DEBUG)
# app.logger.debug('this will show in the log')
# gunicorn_logger = logging.getLogger(‘gunicorn.error’)
@adamshamsudeen
adamshamsudeen / process_pool.py
Created January 25, 2019 14:44
Using all the processors to complete a task in python effectively (multi processing)
import glob
import os
from PIL import Image
import concurrent.futures
def make_image_thumbnail(filename):
# The thumbnail will be named "<original_filename>_thumbnail.jpg"
base_filename, file_extension = os.path.splitext(filename)
thumbnail_filename = f"{base_filename}_thumbnail{file_extension}"
import logging
import logging.handlers as handlers
import time
logger = logging.getLogger('my_app')
logger.setLevel(logging.INFO)
# Here we define our formatter
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
@adamshamsudeen
adamshamsudeen / docker.sh
Created January 10, 2019 11:50
Pushing to google container registry
gcloud auth configure-docker
#gcloud project name - deeplearning-181416
#local image name - eminn/grafana-dashboard
#grafane-image is image and v1 is the tag
docker tag eminn/grafana-dashboard gcr.io/deeplearning-181416/grafane-image:v1
docker push gcr.io/deeplearning-181416/grafane-image:v1