Skip to content

Instantly share code, notes, and snippets.

View ngnam's full-sized avatar

Nguyen Van Nam ngnam

View GitHub Profile
Name : Sam
Serial : eJzzzU/OLi0odswsqglOzK0xsjQzNzI2NjA1q3GuMQQAnJAJjw==
Name: Flash
Serial: eNrzzU/OLi0odswsqnHLSSzOqDGoca7JKCkpsNLXLy8v1ytJTczVLUotKNFLzs8FAJHYETc=
if anyone wants to thank ETH: 0x527c2aB55b744D6167dc981576318af96ed26676
Thank you!
@ngnam
ngnam / error-handler.intercepter.ts
Created January 4, 2019 12:13
error-handler.intercepter.ts
import { Injectable } from '@angular/core';
import {
HttpEvent,
HttpInterceptor,
HttpHandler,
HttpRequest,
HttpResponse
} from '@angular/common/http';
import { Observable } from 'rxjs';
import { catchError } from 'rxjs/operators';
/**
* Simple logger system with the possibility of registering custom outputs.
*
* 4 different log levels are provided, with corresponding methods:
* - debug : for debug information
* - info : for informative status of the application (success, ...)
* - warning : for non-critical errors that do not prevent normal application behavior
* - error : for critical errors that prevent normal application behavior
*
* Example usage:
@ngnam
ngnam / cache.interceptor
Created January 25, 2019 13:43
Cache interceptor Angular
import { Injectable } from '@angular/core';
import {
HttpEvent,
HttpInterceptor,
HttpHandler,
HttpRequest,
HttpResponse
} from '@angular/common/http';
import { Observable, Subscriber } from 'rxjs';
@ngnam
ngnam / .travis.yml
Created April 15, 2019 06:44
.travis.yml simpler
dist: trusty
sudo: false
language: node_js
node_js:
- '10 '
cache:
directories:
- ./node_modules
@ngnam
ngnam / settings.json
Last active July 18, 2019 14:43
.vscode/settings.json
{
"workbench.iconTheme": "material-icon-theme",
"peacock.favoriteColors": [
{
"name": "Angular Red",
"value": "#b52e31"
},
{
"name": "JavaScript Yellow",
"value": "#f9e64f"
import { HttpClient, HttpEventType, HttpRequest } from "@angular/common/http";
import { Injectable } from "@angular/core";
import { Observable, of } from "rxjs";
@Injectable({ providedIn: "root" })
export class FileService {
constructor(private readonly http: HttpClient) { }
upload(files: FileList): Observable<number> {
if (files.length === 0) {
import { Injectable } from '@angular/core';
import {
HttpClient,
HttpHeaders,
HttpParams,
HttpResponse
} from '@angular/common/http';
import { Observable, of } from 'rxjs';
import { map, catchError } from 'rxjs/operators';