Skip to content

Instantly share code, notes, and snippets.

View iamonuwa's full-sized avatar
💭
Learning 🦀

Onuwa Nnachi Isaac iamonuwa

💭
Learning 🦀
View GitHub Profile
@Zyzle
Zyzle / auth.guard.ts
Created July 21, 2016 10:32
Angular 2 Firebase auth guard
import { Injectable } from '@angular/core';
import { CanActivate, Router } from '@angular/router';
import { FirebaseAuth, FirebaseAuthState } from 'angularfire2';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private auth: FirebaseAuth, private router: Router) { }
@swapnilmishra
swapnilmishra / Carddetection.js
Last active January 15, 2020 18:28
Javascript function to detect type of debit/credit card
function getCardType(cardNum) {
if(!luhnCheck(cardNum)){
return "";
}
var payCardType = "";
var regexMap = [
{regEx: /^4[0-9]{5}/ig,cardType: "VISA"},
{regEx: /^5[1-5][0-9]{4}/ig,cardType: "MASTERCARD"},
{regEx: /^3[47][0-9]{3}/ig,cardType: "AMEX"},