Skip to content

Instantly share code, notes, and snippets.

View NazemMahmud's full-sized avatar

Nazem Mahmud Piash NazemMahmud

View GitHub Profile
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { FlexLayoutModule } from '@angular/flex-layout';
import { BasicPaginationComponent } from './basic-pagination.component';
import {MatToolbarModule} from '@angular/material';
@NgModule({
declarations: [
BasicPaginationComponent,
],
import {AfterViewInit, Component, Input, OnInit} from '@angular/core';
import {BehaviorSubject} from 'rxjs';
interface State {
page: number;
pageOffset: number;
}
@Component({
selector: 'basic-pagination',
<mat-toolbar *ngIf=" length > 0">
<span style="margin-left: 20%" class="responsive-view"> {{ 1 + (pageOffset * (pageIndex - 1)) }}
- {{ (pageOffset * pageIndex) <= length ? pageOffset * pageIndex : length }}
of {{ length }}</span>
<span style="margin-left: 20%" class="responsive-view margin-for-mobile">
<button [disabled]="pageIndex <= 1" (click)="getFirstPage()">
<i class="material-icons">first_page</i>
</button>
<button [disabled]="pageIndex <= 1" (click)="getPreviousPage()">
<i class="material-icons">chevron_left</i>
.mat-toolbar {
font-size: 12px;
color: rgba(0,0,0,.54);
}
button {
border: none !important;
background-color: transparent;
}
@media(max-width: 576px) {
@NazemMahmud
NazemMahmud / browser-language-codes.js
Created August 31, 2021 01:26 — forked from wpsmith/browser-language-codes.js
JS: Object of Browser Language Codes
// <![CDATA[
var langCodes = {
"af": "Afrikaans",
"sq": "Albanian",
"an": "Aragonese",
"ar": "Arabic (Standard)",
"ar-dz": "Arabic (Algeria)",
"ar-bh": "Arabic (Bahrain)",
"ar-eg": "Arabic (Egypt)",
"ar-iq": "Arabic (Iraq)",
@NazemMahmud
NazemMahmud / bank_sources.txt
Last active January 25, 2023 05:48
Browser Language Codes and symbols for currency
List of bank sources:
[
"imf": {
"description": "The International Monetary Fund (IMF) is an organization of 188 countries, working to foster global monetary cooperation, secure financial stability, facilitate international trade, promote high employment and sustainable economic growth, and reduce poverty around the world.",
"source": "imf",
"name": "International Monetary Fund",
"source_url": "http://www.imf.org/",
"available_from_date": "2020-05-05"
},
@NazemMahmud
NazemMahmud / KMP preprocess pattern.js
Last active December 11, 2021 20:22
Pre process pattern string for KMP algorithm
function preProcess(pattern) {
let lps = new Array(pattern.length);
let i = 0, j = 1; lps[0] = 0;
while (j < pattern.length) {
if(pattern[j] == pattern[i]) {
lps[j] = i + 1;
i++;
j++;
} else if(i != 0) {
i = lps[i-1];
@NazemMahmud
NazemMahmud / KMP-substring-search.js
Last active December 11, 2021 20:30
KMP algorithm for substring search
/**
* @param {string} haystack
* @param {string} needle
* @return {number}
*/
function KMP(text, pattern){
let LPS = preProcess(pattern);
let i=0, j=0;
while(i < text.length && j < pattern.length){
if(text[i] == pattern[j]){
@NazemMahmud
NazemMahmud / main.component.html
Last active December 18, 2021 10:39
Angular Material: main component html file for pagination sample
<table mat-table *ngIf="dataSource; else noDataFound" [dataSource]="dataSource">
<!-- Name Column -->
<ng-container matColumnDef="name">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Name</th>
<td mat-cell *matCellDef="let row"> {{row.name}} </td>
</ng-container>
<!-- Email Column -->
<ng-container matColumnDef="email">
<th mat-header-cell *matHeaderCellDef mat-sort-header> Email </th>
@NazemMahmud
NazemMahmud / main.component.ts
Last active December 18, 2021 11:10
Angular Material: main component ts file for pagination sample
import {AfterViewInit, Component, OnDestroy, OnInit, ViewChild} from '@angular/core';
import {Subject} from 'rxjs';
import {takeUntil} from 'rxjs/operators';
import {MatTableDataSource} from '@angular/material';
import {MainService} from './service/main.service';
// this will be your shared component path
import {BasicPaginationComponent} from '../shared/components/basic-pagination/basic-pagination.component';
@Component({