Skip to content

Instantly share code, notes, and snippets.

View iamumairayub's full-sized avatar

Umair Ayub iamumairayub

View GitHub Profile
@iamumairayub
iamumairayub / setup_selenoid.sh
Created December 26, 2023 06:57
Setup Selenoid and Selenoid UI with auth protected on Ubuntu.
timedatectl set-timezone America/Toronto
mkdir /home/selenoid
cd /home/selenoid
apt update -y
sudo apt-get install -y docker.io
sudo systemctl start docker
sudo systemctl enable docker
rm -rf cm_linux_amd64
wget https://github.com/aerokube/cm/releases/download/1.8.5/cm_linux_amd64
chmod +x cm_linux_amd64
@iamumairayub
iamumairayub / s3_cleanup.py
Created January 22, 2022 07:13
Python script to delete files from S3 storage service that are N days old.
from boto3 import client, Session
from botocore.exceptions import ClientError
from datetime import datetime, timezone
import argparse
if __name__ == '__main__':
parser = argparse.ArgumentParser()
parser.add_argument('--access_key_id', required=True)
@iamumairayub
iamumairayub / scrapy.py
Created August 26, 2021 09:20
Use settings of Scrapy Spider as provided in command line arguments or sent by ScrapyD.
import sys
class MySpider(scrapy.Spider):
name = 'my_spider'
CONCURRENT_REQUESTS = 10
for x in sys.argv:
if 'CONCURRENT_REQUESTS=' in x:
CONCURRENT_REQUESTS = x.split('CONCURRENT_REQUESTS=')[1]
@iamumairayub
iamumairayub / slowScrollToElement.py
Last active June 26, 2022 13:17
Slowly scroll to an element and make it visible in view-port in Python Selenium
def slow_scroll_to_element(self, driver, element_selector=None, target_yth_location=None):
current_scroll_position = int(driver.execute_script("return window.scrollY"))
if element_selector:
target_yth_location = int(driver.execute_script("return document.querySelector('{}').getBoundingClientRect()['top'] + window.scrollY".format(element_selector)))
scrollSpeed = 100 if target_yth_location-current_scroll_position > 0 else -100
def chunks(a, n):
k, m = divmod(len(a), n)