Skip to content

Instantly share code, notes, and snippets.

View foyzulkarim's full-sized avatar
🚀
building awesome stuffs

Foyzul Karim foyzulkarim

🚀
building awesome stuffs
View GitHub Profile
@foyzulkarim
foyzulkarim / usages.js
Created March 3, 2024 12:10
Simplify Express.js Validation: Sync Joi and Mongoose Schemas
const viewModelProps = {
title: { type: String, isRequired: true, minLength: 5, unique: true, index: true },
category: { type: String, isRequired: true },
}
// in mongoose
const videoSchema = new mongoose.Schema({
...generateSchema(true, viewModelProps),
duration: {
type: Number,
@foyzulkarim
foyzulkarim / index.js
Created July 14, 2021 15:55
Webinar on Node.js : Express.js handle 200K+ request in 10seconds using Cluster and PM2
const express = require('express')
var numCPUs = require('os').cpus().length;
const cluster = require('cluster');
const app = express()
app.get('/', (req, res) => {
res.send('Hello World!')
});
@foyzulkarim
foyzulkarim / sampleREADME.md
Created January 7, 2019 19:09 — forked from FrancesCoronel/sampleREADME.md
A sample README for all your GitHub projects.

FVCproductions

INSERT GRAPHIC HERE (include hyperlink in image)

Repository Title Goes Here

Subtitle or Short Description Goes Here

@foyzulkarim
foyzulkarim / Program.cs
Created September 8, 2018 03:51
Data Migration using Threading in C#
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Linq.Dynamic;
using System.Threading;
using System.Threading.Tasks;
using System.Transactions;
using Core = BizBookCoreDbModelLibrary;
using BizBookDbModelLibrary;
@foyzulkarim
foyzulkarim / AzureSigninFunction.cs
Created April 20, 2018 10:50
Azure Function is used here as ASP.NET Identity Token provider for SPA Applications. Then this token will be used for other secured API calls, eg. saving a Sale entity to database
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Threading.Tasks;
using Microsoft.Azure.WebJobs;
using Microsoft.Azure.WebJobs.Extensions.Http;
using Microsoft.Azure.WebJobs.Host;
namespace FunctionApp1
{
@foyzulkarim
foyzulkarim / Get Text From PDF using C# and iTextSharp
Created February 9, 2018 15:25
One of my clients who is currently using BizBook, used Wave for some months, but while they grew bigger, wave stopped supporting to download the invoices as a bulk excel or csv. So, when they decided to jump into BizBook, then they had to export their all existing data into my system. Since the wave didn’t allow csv / excel anymore, so I had no …
private static IEnumerable<string> GetTextFromPDF(string invoicePdf)
{
var fromPdf = new List<string>();
using (PdfReader reader = new PdfReader(invoicePdf))
{
for (int i = 1; i <= reader.NumberOfPages; i++)
{
string value = PdfTextExtractor.GetTextFromPage(reader, i);
List<string> list = value.Split(new[] { "\n" }, StringSplitOptions.None).ToList();
list.RemoveAll(Match);
@foyzulkarim
foyzulkarim / BaseReportService.cs
Created February 4, 2018 18:15
Create default instance of the provided type
public class BaseReportService
{
protected T CreateDefault<T>(Type t, string shopId) where T : BaseReport
{
var report = Activator.CreateInstance(t) as BaseReport;
report.Id = Guid.NewGuid().ToString();
report.Created = DateTime.Now;
report.Modified = DateTime.Now;
report.CreatedBy = "System";
report.ModifiedBy = "System";
<button type="button" class="btn btn-inline" ng-click="vm.back()"><</button>
<button type="button" class="btn btn-inline" ng-click="vm.print()">Print</button>
<button type="button" class="btn btn-inline" ng-click="vm.downloadPdf('receipt')">Pdf</button>
<div class="container-fluid" id="receipt" style="background: white">
<style type="text/css">
.invoice-title h2, .invoice-title h3 {
display: inline-block;
}
.table > tbody > tr > .no-line {
@foyzulkarim
foyzulkarim / AuthorizationController.cs
Created August 22, 2017 16:12
Role-Based-Access-Control Authorization Logic based on ASP.NET Identity and System.Runtime.Caching.MemoryCache
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Net.Http;
using System.Runtime.Caching;
using System.Web.Http;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.Owin;
@foyzulkarim
foyzulkarim / VSTS Build Fail Nuget Restore Error Access Denied
Created August 21, 2017 07:48
Suddenly our build system starts failing continuously for all of the builds of all repositories. We didn't change anything in the VSTS and we don't have a clue what might be the cause. If it were due to our code/repository, then the other existing previously succeeded builds should have ran well. One thing I would like to add here is, We have be…
2017-08-21T07:35:21.7899827Z ##[debug]Evaluating condition for step: 'NuGet restore Exception/Exception.sln'
2017-08-21T07:35:21.7899827Z ##[debug]Evaluating: succeeded()
2017-08-21T07:35:21.7909820Z ##[debug]Evaluating succeeded:
2017-08-21T07:35:21.7909820Z ##[debug]=> (Boolean) True
2017-08-21T07:35:21.7909820Z ##[debug]Expanded: True
2017-08-21T07:35:21.7909820Z ##[debug]Result: True
2017-08-21T07:35:21.7909820Z ##[section]Starting: NuGet restore Exception/Exception.sln
2017-08-21T07:35:21.7909820Z ==============================================================================
2017-08-21T07:35:21.7909820Z Task : NuGet Installer
2017-08-21T07:35:21.7909820Z Description : Installs or restores missing NuGet packages