Skip to content

Instantly share code, notes, and snippets.

View cironunes's full-sized avatar
🎯
Focusing

Ciro Nunes cironunes

🎯
Focusing
View GitHub Profile
@cironunes
cironunes / app.module.ts
Created August 9, 2017 21:19
How to register an Interceptor into an Angular 4.3.0+ application
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
@NgModule({
imports: [],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
]
})
export class AppModule {}
@cironunes
cironunes / app.module.ts
Created August 9, 2017 21:19
How to register an Interceptor into an Angular 4.3.0+ application
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
@NgModule({
imports: [],
providers: [
{ provide: HTTP_INTERCEPTORS, useClass: AuthInterceptor, multi: true }
]
})
export class AppModule {}
@cironunes
cironunes / interceptor.ts
Last active August 9, 2017 18:32
HttpInterceptor interface
interface HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>>;
}
@cironunes
cironunes / auth.interceptor.ts
Last active August 9, 2017 20:51
Angular 4.3.0+ Auth HttpInterceptor example
import { Injectable } from '@angular/core';
import { HttpInterceptor, HttpRequest, HttpHandler, HttpEvent, HttpEventType } from '@angular/common/http';
import { Observable } from 'rxjs/Observable';
export class AuthInterceptor implements HttpInterceptor {
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<HttpEventType.Response>> {
const authReq = req.clone({
setHeaders: { Authorization: `Bearer authtest` }
});
@cironunes
cironunes / 01-index.html
Last active October 7, 2015 18:19
Simple HTML file to start working with Angular 2 Alpha Preview (Traceur + SystemJS + TypeScript)
<!DOCTYPE html>
<html>
<head>
<title>My First Angular 2 app</title>
</head>
<body>
<my-app>Loading...</my-app>
<!-- dependencies -->
<script src="https://code.angularjs.org/tools/traceur-runtime.js"></script>
@cironunes
cironunes / ng-modules.md
Last active May 24, 2016 07:48
A curated list of AngularJS modules and tools
@cironunes
cironunes / services.js
Last active December 30, 2015 11:19
sample service
'use strict';
angular.module('myApp.services', [])
.value('version', '0.1')
.constant('API_KEY', 't5vzuyfb49c2sd56sjz4bc2p')
.factory('$rtmFactory', function($http, API_KEY){
var countries = [
{name:'USA', code:'us'},
{name:'UK', code:'uk'},
{name:'France', code:'fr'}
@cironunes
cironunes / apps.sh
Last active September 8, 2023 21:47 — forked from zenorocha/.hyper.js
#!/bin/sh
# homebrew-cask
brew tap phinze/homebrew-cask
brew install brew-cask
# browsers
brew cask install google-chrome
brew cask install opera-next
@cironunes
cironunes / fn.js
Created August 20, 2013 21:54
simple express GET route
app.get('loggedin', function(req, res) {
//body...
});
@cironunes
cironunes / _state.scss
Last active December 18, 2015 04:58
is-observable state
/*= @group State
---------------------------------------------------------------------- */
.is-hidden {
display: none;
}
.is-hidden--floated {
position: absolute;
visibility: hidden;
@include opacity(0);