Skip to content

Instantly share code, notes, and snippets.

View ptesser's full-sized avatar

Paolo Tesser ptesser

View GitHub Profile
@ptesser
ptesser / tsconfig.json
Last active March 3, 2020 23:32
TS config with strict rules
{
"compilerOptions": {
...
"noImplicitAny": true,
"noUnusedParameters": true,
"noImplicitReturns": true,
"noImplicitThis": true,
...
}
}
@ptesser
ptesser / tslint.json
Last active January 30, 2019 22:12
TS lint with default Angular rules
{
"rulesDirectory": [
"node_modules/codelyzer"
],
"extends": [
"tslint:recommended"
],
"rules": {
"arrow-return-shorthand": true,
"callable-types": true,
@ptesser
ptesser / auth.service.ts
Last active September 17, 2019 21:07
Refresh Token interceptor and authentication service used to store local user information in an Ionic 3 project with the Pub/Sub pattern implemented with RxJS BehaviorSubjet.
const X_WWW_FORM_URLENCODED_OPTIONS = {
headers: new HttpHeaders().set('Content-Type', 'application/x-www-form-urlencoded')
};
export const USER_KEY = 'user';
export const USERNAME_KEY = 'username';
export const TOKEN_KEY = 'token';
export const INSTITUTION_KEY = 'institution';
@Injectable()
@ptesser
ptesser / tsconfig.json
Created March 7, 2019 23:14
Configure @alias in Ionic 3 with TypeScript. This is done also to configure environments.
{
"compilerOptions": {
"paths": {
"@src/*": ["./*"],
"@app/*": ["./app/*"],
"@pages/*": ["./pages/*"],
"@env": [ "environments/environment" ]
}
},
@ptesser
ptesser / operators.ts
Created May 8, 2019 13:19
RxJS operator functions
import { Observable } from 'rxjs';
import { filter } from 'rxjs/operators';
function inputIsNotNullOrUndefined<T>(input: null | undefined | T): input is T {
return input !== null && input !== undefined;
}
export function isNotNullOrUndefined<T>() {
return (source$: Observable<null | undefined | T>) =>
source$.pipe(
// Youtube Keys
YOUTUBE_API_KEY: 'AIzaSyBSnGWkvGIBpXONyAKv5Gt3OofBv0IaHkw',
// (angular-courses project in p.tesser921 account) AIzaSyDF0QpmbBwnZsNCCZeBln2hFjqD2KiSGkk
YOUTUBE_API_URL: 'https://www.googleapis.com/youtube/v3',
// Trending params
const params: string = [
'chart=mostPopular',
'regionCode=IT',
'part=snippet,contentDetails,statistics',