Skip to content

Instantly share code, notes, and snippets.

View HammadMaqbool's full-sized avatar
🏠
Working from home

HammadMaqbool HammadMaqbool

🏠
Working from home
View GitHub Profile
@HammadMaqbool
HammadMaqbool / PasswordGenerator.cs
Last active May 14, 2024 08:17
This is code in C# you can use to generate random strong password - I got it from an answer on the stackoverflow and saving it here for so anyone can use it.
using System.Security.Cryptography;
public class PasswordGenerator
{
public int MinimumLengthPassword { get; private set; }
public int MaximumLengthPassword { get; private set; }
public int MinimumLowerCaseChars { get; private set; }
public int MinimumUpperCaseChars { get; private set; }
public int MinimumNumericChars { get; private set; }
@HammadMaqbool
HammadMaqbool / CustomUserFactory.cs
Last active February 18, 2024 16:11
This is the custome user factory class for using with role based authorization in Blazor Apps got this class code from the book "Blazor in action" by Chris Sainty
using Microsoft.AspNetCore.Components.WebAssembly.Authentication.Internal;
using Microsoft.AspNetCore.Components.WebAssembly.Authentication;
using System.Security.Claims;
using System.Text.Json;
namespace {Enter your namespace name here}
{
public class CustomUserFactory<TAccount> : AccountClaimsPrincipalFactory<RemoteUserAccount>
{
public CustomUserFactory(IAccessTokenProviderAccessor accessor) : base(accessor) { }
#include<iostream>
using namespace std;
class Animal
{
public:
void virtual Speak()
{
//no code. . .
}
};
@HammadMaqbool
HammadMaqbool / polymorphism-virtual-function.cpp
Created October 24, 2023 16:07
C++ Example code to understand the concept of Polymorphish using Virtual Function
#include<iostream>
using namespace std;
class Animal
{
public:
virtual void Sound()
{
//No code. . .
}
@HammadMaqbool
HammadMaqbool / PaginationAspCoreMVC6.md
Created April 24, 2022 16:45
This is the complete code of how to implement the pagination in the AspNetCore MVC (.NET6) all portions are defined.

Make a class PaginatedList in Model folder 📂

public class PaginatedList<T> : List<T>
    {
        public int PageIndex { get; private set; }
        public int TotalPages { get; private set; }

        public PaginatedList(List<T> items, int count, int pageIndex, int pageSize)
        {
String[] requestedColumns = { CallLog.Calls.CACHED_NUMBER_LABEL, CallLog.Calls.DURATION };
Cursor calls = managedQuery( CallLog.Calls.CONTENT_URI, requestedColumns,
CallLog.Calls.CACHED_NUMBER_LABEL+ " = ?", new String[] { "HourlyClient123" } , null);
Log.d(DEBUG_TAG, "Call count: " + calls.getCount());
int durIdx = calls.getColumnIndex(CallLog.Calls.DURATION);
int totalDuration = 0;
calls.moveToFirst();
while (!calls.isAfterLast())
{
Log.d(DEBUG_TAG, "Duration: " + calls.getInt(durIdx));
@HammadMaqbool
HammadMaqbool / DataDictionaryQueries.sql
Last active April 5, 2020 07:54
Attribute name availablity checking
/*Check Attribute name availablity*/
SELECT TABLE_NAME FROM   DataBaseName_Here.INFORMATION_SCHEMA.COLUMNS WHERE  COLUMN_NAME = ‘Name'
--To check all the tables available in the Database
SELECT TABLE_NAME, TABLE_TYPE FROM DataBaseName_Here.INFORMATION_SCHEMA.TABLES ORDER BY TABLE_NAME
--To Get the list of columns
SELECT COLUMN_NAME FROM DataBaseName_Here.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'Table Name here'
/*Queries to get all the data*/
@HammadMaqbool
HammadMaqbool / Number_Guess_Game.py
Created February 22, 2020 08:32
This gist contain python based number guess game
import random
Comp_guess_number = random.randint(1,5)
total_number_of_Attempts = 3
cuurent_attempt =1
while(cuurent_attempt<=total_number_of_Attempts):
if cuurent_attempt == total_number_of_Attempts:
print("This is last attempt")
@HammadMaqbool
HammadMaqbool / Random Question Generator
Last active April 18, 2022 18:33
A C++ based program to produce random questions
a console-based application for school teachers.
This application will auto generate questions for Grades 1, 2, 3, 4 and 5.
Using this application teacher will be able to give different paper to each student
#include<iostream.h>
#include<conio.h>
void main()
{
int location=-1,item;
int arr[9];
cout<<"Enter the Data";
for(int i=0; i<=9;i++)
{
cin>>arr[i];