Skip to content

Instantly share code, notes, and snippets.

View ali-kamalizade's full-sized avatar
🎩
Sunhat

Ali ali-kamalizade

🎩
Sunhat
View GitHub Profile
@ali-kamalizade
ali-kamalizade / ci-with-nx.yml
Last active May 19, 2022 08:37
A sample GitHub workflow using Nx
ci_web:
name: "Build & Tests & Lint"
runs-on: ubuntu-latest
steps:
- name: "Checkout project"
uses: actions/checkout@v3
with:
fetch-depth: 0
@ali-kamalizade
ali-kamalizade / disabled-http-logging-pino.ts
Created August 8, 2021 13:06
Customized logging in Express.js using pino middleware
import pino from 'express-pino-logger';
// use middleware
app.use(
pino({
autoLogging: {
ignorePaths: ['/healthcheck']
}
})
);
@ali-kamalizade
ali-kamalizade / my.component.ts
Last active June 29, 2025 17:21
How to cancel HTTP requests when navigating to another route in Angular apps
import { NavigationStart, Router } from '@angular/router';
import { filter, first, takeUntil } from 'rxjs/operators';
// Use this to abort things like HTTP requests when navigating to another route.
// Example: cancel polling an API when the user navigates to another route.
destroyIfNavigatingToAnotherRoute(currentRoute: string) {
return takeUntil<any>(
this.router.events.pipe(
filter((routerEvent) => routerEvent instanceof NavigationStart && !routerEvent.url.startsWith(currentRoute)),
first()
@ali-kamalizade
ali-kamalizade / disabled-healthcheck-logging.ts
Last active April 22, 2021 21:20
Customized logging in Express.js using morgan middleware
import logger from 'morgan';
// use middleware
app.use(
logger("dev", {
skip(req, _res) {
return req.baseUrl.includes('/healthcheck'); // customize this to your needs
}
})
);
@ali-kamalizade
ali-kamalizade / .gitlab-ci.yml
Last active March 17, 2021 21:11
A GitLab CI configuration with multiple jobs which uses a node image. See also: https://gist.github.com/ali-kamalizade/5b235a7ed35ecff64992f3fd064a2f9b
default:
image: node:12.10.0
before_script:
- npm ci
Build:
script:
- npm run build
Run tests:
@ali-kamalizade
ali-kamalizade / .gitlab-ci.yml
Last active March 17, 2021 21:11
A GitLab CI configuration with multiple jobs which uses an alpine-node image. See also: https://gist.github.com/ali-kamalizade/1ae555eabdafc8e5e24b50514cb104c4
default:
image: mhart/alpine-node:12
before_script:
- npm ci
Build:
script:
- npm run build
Run tests:
@ali-kamalizade
ali-kamalizade / angular-loading-async.html
Last active March 14, 2021 21:19
A simple example of showing a loading indicator in an Angular component while data is being fetched
<div *ngIf="results$ | async as results; else showSpinner">
<ul *ngIf="results.length; else noResults">
<li *ngFor="let result of results">{{ result.name }}</li>
</ul>
<ng-template #noResults>No results found.</ng-template>
</div>
<ng-template #showSpinner>
<app-spinner></app-spinner>
</ng-template>
@ali-kamalizade
ali-kamalizade / compression.md
Last active March 8, 2021 21:45
Examples of enabling compression in Express.js, Dropwizard and Spark

Compress responses using compression middleware in Express.js

app.use(
	compression({
		threshold: 1024 // = 1KB, smaller files will not be compressed
	})
);

Compress responses using the configuration in Dropwizard

@ali-kamalizade
ali-kamalizade / tsconfig.json
Created March 8, 2021 20:51
A sample tsconfig.json file targeting modern browsers that support ES2015
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"module": "esnext",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
@ali-kamalizade
ali-kamalizade / browserslist
Created March 7, 2021 15:37
A custom browserslist file which excludes browsers that do not support ES2015 (e.g. IE11, Opera Mini)
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please see:
# https://github.com/browserslist/browserslist#queries
# You can see what browsers were selected by your queries by running:
# npx browserslist
last 5 Chrome versions
last 5 ChromeAndroid versions