Skip to content

Instantly share code, notes, and snippets.

View ahmedshahriar's full-sized avatar
🏠
Working from home

Ahmed Shahriar Sakib ahmedshahriar

🏠
Working from home
View GitHub Profile
int searchItem(int sist[],int item,int sizeList){
int position=0;
while(position<(sizeList-1)){
if(sist[position]==item){
break;
}else{
position++;}
}
return position;
}
int searchBinary(int arrayList[],int findNum,int first , int last ){
while(first<=last){
int middle =( last+first)/2;
if(arrayList[middle]==findNum)
return middle;
@ahmedshahriar
ahmedshahriar / tpr_fpr_binary_class.py
Created June 8, 2020 17:52
This sample code works on binary classification to generatre True Positive Rate and False Positive Rate (TPR, FPR) by class.
"""This sample code works on binary classification to generatre True Positive Rate and False Positive Rate (TPR, FPR) by class.
Yes denotes positive class and No denotes negative class.
Default value 0 and 1.
Created by Ahmed Shahriar Sakib @ahmedshahriar on 06.08.2020 """
yes_tp = 0
yes_fp = 0
no_tp = 0
no_fp = 0
yes_instances =0
import scrapy
class QuotesSpider(scrapy.Spider):
name = "quotes"
start_urls = [
'http://quotes.toscrape.com/page/1/',
]
def parse(self, response):
import requests
import re
headers = {
'authority': 'www.amazon.com',
'pragma': 'no-cache',
'cache-control': 'no-cache',
'dnt': '1',
'upgrade-insecure-requests': '1',
'user-agent': 'Mozilla/5.0 (X11; CrOS x86_64 8172.45.0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/51.0.2704.64 Safari/537.36',
"""
@ github.com/ahmedshahriar
This code will remove remove non-English words from text
"""
import nltk
# download nltk english corpus
nltk.download('wordnet')
wordnet = set(nltk.corpus.wordnet.words())
"""
code snippet to add/subtract datetime object
https://github.com/ahmedshahriar
"""
from datetime import datetime, timedelta
# addition
d = datetime.now() + timedelta(days=1, weeks=1, hours=19,seconds=1,milliseconds=1,microseconds=1)
"""
simplify price with currency sign to number
"""
# sample
txt = "$5,200"
txt[1:].replace(',','')
# output
# 5200
"""
code snippet for selenium with fake user agent
selenium : https://selenium-python.readthedocs.io/
fake user agent : https://github.com/hellysmile/fake-useragent
https://github.com/ahmedshahriar
"""
from time import sleep
from selenium import webdriver
@ahmedshahriar
ahmedshahriar / .ignore
Created November 27, 2020 16:43
gitignore for python, django , pycharm , env files
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.DS_Store
.idea
.env
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries