Skip to content

Instantly share code, notes, and snippets.

import { catchError, map } from 'rxjs/operators';

const response = this.httpService
  .get('https://abc.com/api/v2/branches')
  .pipe(
    map((response) => response.data),
    catchError((e) => {
      throw new HttpException(e.response.data, e.response.status);
 }),
@paztek
paztek / app.module.ts
Created July 18, 2020 15:50
nestjs-http-service-example-1
import { Module } from '@nestjs/common';
import { HttpModule } from './http/http.module';
import { FooModule } from './foo/foo.module';
@Module({
imports: [
HttpModule,
FooModule, // <- we'll make use of the "augmented" HttpService in this module
],
@bvaughn
bvaughn / index.md
Last active May 4, 2024 11:25
How to use profiling in production mode for react-dom

React recently introduced an experimental profiler API. This page gives instructions on how to use this API in a production release of your app.

Table of Contents

Profiling in production

React DOM automatically supports profiling in development mode for v16.5+, but since profiling adds some small additional overhead it is opt-in for production mode. This gist explains how to opt-in.

@gaearon
gaearon / minification.md
Last active March 4, 2024 12:45
How to Set Up Minification

In production, it is recommended to minify any JavaScript code that is included with your application. Minification can help your website load several times faster, especially as the size of your JavaScript source code grows.

Here's one way to set it up:

  1. Install Node.js
  2. Run npm init -y in your project folder (don't skip this step!)
  3. Run npm install terser

Now, to minify a file called like_button.js, run in the terminal:

@spalladino
spalladino / mysql-docker.sh
Created December 22, 2015 13:47
Backup and restore a mysql database from a running Docker mysql container
# Backup
docker exec CONTAINER /usr/bin/mysqldump -u root --password=root DATABASE > backup.sql
# Restore
cat backup.sql | docker exec -i CONTAINER /usr/bin/mysql -u root --password=root DATABASE