Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Ahmed Shahriar Sakib ahmedshahriar

🏠
Working from home
View GitHub Profile
View binary_search.cpp
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
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 Jun 8, 2020
This sample code works on binary classification to generatre True Positive Rate and False Positive Rate (TPR, FPR) by class.
View tpr_fpr_binary_class.py
"""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
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
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
"""
@ 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
"""
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
"""
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
"""
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 Nov 27, 2020
gitignore for python, django , pycharm , env files
View .ignore
# 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