View binary_search.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int searchItem(int sist[],int item,int sizeList){ | |
int position=0; | |
while(position<(sizeList-1)){ | |
if(sist[position]==item){ | |
break; | |
}else{ | |
position++;} | |
} | |
return position; | |
} |
View binary_search_recursion.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int searchBinary(int arrayList[],int findNum,int first , int last ){ | |
while(first<=last){ | |
int middle =( last+first)/2; | |
if(arrayList[middle]==findNum) | |
return middle; |
View tpr_fpr_binary_class.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""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 |
View scrpay_starter_snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import scrapy | |
class QuotesSpider(scrapy.Spider): | |
name = "quotes" | |
start_urls = [ | |
'http://quotes.toscrape.com/page/1/', | |
] | |
def parse(self, response): |
View amazon_regex_parser_starter_template.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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', |
View non_english_word_removal.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
@ 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()) |
View date_addition_subtraction.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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) |
View simplify_price_string_to_number.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
simplify price with currency sign to number | |
""" | |
# sample | |
txt = "$5,200" | |
txt[1:].replace(',','') | |
# output | |
# 5200 |
View selenium_starter_snippet_with_fake_user_agent.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
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 |
View .ignore
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
OlderNewer