Skip to content

Instantly share code, notes, and snippets.

View umerfaruk's full-sized avatar

Omar Faruk umerfaruk

  • JustEat
  • London, United Kingdom
View GitHub Profile
BlockingCollection<Page> _jobs = new BlockingCollection<Page>();
var tasks = new ConsumerStarter().StartAsyncConsumers(_threadCount, _cancellationToken, DownloadPage);
for (var i = 0; i < _pageCount; i++)
{
_jobs.Add(new Page { PageId = pageIds[i], PageNumber = Path.GetFileNameWithoutExtension(pages[i]), FileName = pages[i] });
}
_jobs.CompleteAdding();
Task.WaitAll(tasks.ToArray(), _cancellationToken);
@umerfaruk
umerfaruk / PDFGenerate.cs
Created July 8, 2020 08:57
PDF Generation
PageSize documentSize;
using (var firstImage = new Bitmap(firstPagePath))
{
documentSize = new PageSize(firstImage.Width, firstImage.Height);
}
using (var pdf = new PdfDocument(new PdfWriter(pdfPath)))
{
using (var writer = pdf.GetWriter())
{
public static async Task<string> GetTextBody(string url)
{
HttpWebRequest myRequest = (HttpWebRequest)WebRequest.Create(url);
myRequest.Method = "GET";
WebResponse myResponse = await myRequest.GetResponseAsync();
StreamReader sr = new StreamReader(myResponse.GetResponseStream(), Encoding.UTF8);
string result = await sr.ReadToEndAsync();
sr.Close();
myResponse.Close();
@umerfaruk
umerfaruk / profile.json
Created October 27, 2019 17:27
Windows terminal configuration
// To view the default settings, hold "alt" while clicking on the "Settings" button.
// For documentation on these settings, see: https://aka.ms/terminal-documentation
{
"$schema": "https://aka.ms/terminal-profiles-schema",
"defaultProfile": "{61c54bbd-c2c6-5271-96e7-009a87ff44bf}",
"profiles":
[
{
@umerfaruk
umerfaruk / save-rekhta.py
Last active April 16, 2023 06:48
Saves the rekhta book as images to your disk.
# Rekhta Import
# Please make sure that you are not using scaling on your windows computer before running this script
# Running this script will cause partial images to be recorded
# Requires the selenium web driver. Check this link https://selenium-python.readthedocs.io/installation.html
# This script uses firefox. Please make sure you have firefox installed on your computer.
#pip install selenium
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
@umerfaruk
umerfaruk / elasticsearch-cheatsheet.txt
Created August 21, 2017 10:10 — forked from stephen-puiszis/elasticsearch-cheatsheet.txt
Elasticsearch Cheatsheet - An Overview of Commonly Used Elasticsearch API Endpoints and What They Do
# Elasticsearch Cheatsheet - an overview of commonly used Elasticsearch API commands
# cat paths
/_cat/allocation
/_cat/shards
/_cat/shards/{index}
/_cat/master
/_cat/nodes
/_cat/indices
/_cat/indices/{index}