Skip to content

Instantly share code, notes, and snippets.

View doroudi's full-sized avatar
:octocat:
Develop and Learn!

Saeid Doroudi doroudi

:octocat:
Develop and Learn!
View GitHub Profile
@doroudi
doroudi / CSharpThrottle.cs
Created June 2, 2022 06:54
throttling async tasks using semaphore in c#
public async Task SaveEmployees(ICollection<EmployeeImportDto> employees)
{
// set maximum 8 concurrent tasks
var throttler = new SemaphoreSlim(initialCount: 8);
var tasks = employees.Select(async item =>
{
await throttler.WaitAsync();
try
{
await SaveEmployee(item).ConfigureAwait(false);
@doroudi
doroudi / numberToPersianAlphabet.js
Last active February 26, 2021 12:47
تبدیل عدد به حروف فارسی با vuejs filter
const NumberToAlphabetFilter = function(input) {
let temp = "";
let trilliongan = Math.floor(input / 1000000000000000);
let sadbilliongan = Math.floor(
(input - trilliongan * 1000000000000000) / 100000000000000
);
let dahbilliongan = Math.floor(
(input -
(trilliongan * 1000000000000000 + sadbilliongan * 100000000000000)) /
10000000000000
import Vue from 'vue'
Vue.filter('replaceArabicLetters', value => {
const letters = {
'ك': 'ک',
'دِ': 'د',
'بِ': 'ب',
'زِ': 'ز',
'ذِ': 'ذ',
'شِ': 'ش',
@doroudi
doroudi / topMovies.py
Created October 17, 2019 21:12
Get Top Movies with details from imdb.com
# -*- coding: utf-8 -*-
import scrapy
import json
from ..items import MovieItem
class TopmoviesSpider(scrapy.Spider):
name = 'topMovies'
allowed_domains = ['imdb.com']
start_urls = ['https://www.imdb.com/chart/top/']
@doroudi
doroudi / items.py
Created October 17, 2019 19:42
Movies Model Class for imdb.com crawler
class MovieItem(scrapy.Item):
url = scrapy.Field()
name = scrapy.Field()
image = scrapy.Field()
genre = scrapy.Field()
contentRating = scrapy.Field()
actor = scrapy.Field()
creator = scrapy.Field()
description = scrapy.Field()
datePublished = scrapy.Field()
@doroudi
doroudi / topMovies.py
Last active October 17, 2019 20:22
Get Movies Information
# -*- coding: utf-8 -*-
import scrapy
class TopmoviesSpider(scrapy.Spider):
name = 'topMovies'
allowed_domains = ['imdb.com']
start_urls = ['https://www.imdb.com/chart/top/']
def parse(self, response):
@doroudi
doroudi / topMovies.py
Last active October 17, 2019 20:23
Get movies title from imdb.com top movies
# -*- coding: utf-8 -*-
import scrapy
class TopmoviesSpider(scrapy.Spider):
name = 'topMovies'
allowed_domains = ['imdb.com']
start_urls = ['https://www.imdb.com/chart/top/']
def parse(self, response):