Skip to content

Instantly share code, notes, and snippets.

View franklinjavier's full-sized avatar

Franklin Javier franklinjavier

View GitHub Profile
@franklinjavier
franklinjavier / gist:ab06e97e4fb0b1a2b56cbed077ba8028
Created August 24, 2018 17:14
função para validar cartão de crédito
//campo para validação da bandeira de cartão
function getCreditCardLabel(c){
// SOMENTE NÚMEROS
let re = new RegExp("^\d+$");
if (c.match(re) != null)
return false;
let brands = {};
brands["elo"] = {
regexpBin: /^401178|^401179|^431274|^438935|^451416|^457393|^457631|^457632|^504175|^627780|^636297|^636368|^(506699|5067[0-6]\d|50677[0-8])|^(50900\d|5090[1-9]\d|509[1-9]\d{2})|^65003[1-3]|^(65003[5-9]|65004\d|65005[0-1])|^(65040[5-9]|6504[1-3]\d)|^(65048[5-9]|65049\d|6505[0-2]\d|65053 [0-8])|^(65054[1-9]|6505[5-8]\d|65059[0-8])|^(65070\d|65071[0-8])|^65072[0-7]|^(65090[1-9]|65091\d|650920)|^(65165[2-9]|6516[6-7]\d)|^(65500\d|65501\d)|^(65502[1-9]|6550[3-4]\d|65505[0-8])/,
regexpFull: /^(401178|401179|431274|438935|451416|457393|457631|457632|504175|627780|636297|636368|(506699|5067[0-6]\d|50677[0-8])|(50900\d|5090[1-9]\d|509[1-9]\d{2})|65003[1-3]|(65003[5-9]|65004\d|65005[0-1])|(65040[5-9]|6504[1-3]\d)|(65048[5-9]|65049\d|6505[0-2]\d|65053[0-8])|(65054[1-9]| 6505[5-8]\d|65059[0-8])|(65070\d|65071[0-8])|65072[0-7]|(65090[1-9]|65091\d|650920)|(65165[2-9]|6516[6-7]\d)|(65500\d|65501\d)|(65502[1-9]|6550[3-4]\d|65505[0-8]))[0-9]{10,12}/,
regexpCvv: /^\d{3}$/,
};
@franklinjavier
franklinjavier / redux-fetch-interceptors.js
Created September 9, 2017 00:56 — forked from jaysoo/redux-fetch-interceptors.js
Redux + fetch interceptors
/*
* WARNING: Mutates the fetchContext argument (by default the window or global context).
*
* A crude way to intercept fetch responses, and dispatch actions as needed. Using this
* for more global app concerns, where I may want to dispatch actions depending on the response
* status or body. e.g. When seeing a 401, dispatch a logout action.
*
* In most cases, I'd recommend using a middlware as shown in redux's real-world example.
* (https://github.com/reactjs/redux/blob/master/examples/real-world/middleware/api.js)
*
@franklinjavier
franklinjavier / serviceworker_wk.js
Created September 1, 2016 15:31 — forked from kimhogeling/serviceworker_wk.js
Service Worker of the shopping24 hacking days wohnklamotte prototype
/**
* KH: Warning! This is part of a prototype made during our early 2016 hacking days and is not suitable for production!
*/
const VERSION = 's24-wokl-social-v6'
const CACHE_FILES = [
'/',
'/index.html',
'/public/css/card.css',
@franklinjavier
franklinjavier / gist:91607963994b04b29ef9
Created March 22, 2016 03:34
Walmart Mobile node.js Setup

Overview

We run multiple server processes in two data centers. Each process listens on two ports, one for HTTP and one for HTTPS. HTTPS is terminated by Apache prior to reaching node.js. HTTP goes directly from the client to node.js (through a master load balancer). We do not use clusters. We slice our physical servers into thin virtual machines running SmartOS, each with about 3GB of memory designed for a single node.js process.

Our node.js servers are hapi.js servers using the composer functionality and plugins architecture. We have three sets of plugins loaded: mobile web front end experience (single page app), legacy API reverse proxy, and monitoring.

We also serve original node.js services off another server zone which runs closed source plugins using hapi.

Analytics

@franklinjavier
franklinjavier / frp.md
Created February 9, 2016 17:23 — forked from ohanhi/frp.md
Learning FP the hard way: Experiences on the Elm language

Learning FP the hard way: Experiences on the Elm language

by Ossi Hanhinen, @ohanhi

with the support of Futurice 💚.

Licensed under CC BY 4.0.

Foreword

@franklinjavier
franklinjavier / bins-elo.md
Created November 26, 2015 11:16 — forked from k8adev/bins-elo.md
Bins para validação de cartões de crédito ELO

Validação para cartão de crédito ELO

Bins

Os bins foram ordenados pelo início dos 4 primeiros dígitos.

  • 4011
  • 4389 3 5
  • 4514 1 6
  • 4576
@franklinjavier
franklinjavier / nvm-node-npm.sh
Created October 16, 2015 01:17
Install nvm, node stable and npm
#!/usr/bin/env bash
set -e
echo "Installing nvm..."
[ -d ~/.nvm ] && rm -rf ~/.nvm
git clone https://github.com/creationix/nvm.git ~/.nvm
cd ~/.nvm
git checkout `git describe --abbrev=0 --tags`
cd - >/dev/null
@franklinjavier
franklinjavier / LazyLoad.js
Created October 10, 2015 14:31 — forked from yocontra/LazyLoad.js
lazy loading react components, useful for video/audio/etc
var React = require('react');
var events = require('add-event-listener');
var isVisible = require('../isVisible');
var LazyLoad = React.createClass({
displayName: 'LazyLoad',
propTypes: {
distance: React.PropTypes.number,
component: React.PropTypes.node.isRequired,
children: React.PropTypes.node.isRequired
@franklinjavier
franklinjavier / passport-routes.js
Created October 8, 2015 00:24 — forked from nkbt/passport-routes.js
Passport.js Routes
"use strict";
var passport = require('./passport');
var config = {
redirectBack: redirectBack
}
function redirectBack(req, res) {
res.redirect(req.param('__back') && decodeURIComponent(req.param('__back')) || '/');
}