Skip to content

Instantly share code, notes, and snippets.

View SeanJM's full-sized avatar

Sean MacIsaac SeanJM

  • Sean J MacIsaac
  • Montreal, QC
View GitHub Profile
@SeanJM
SeanJM / getCreditCardIssuer.js
Created March 3, 2017 14:27
A function which returns an object based on the credit card number with credit card issuer properties
function getCreditCardIssuer(number) {
number = number.toString();
if (/^4[0-9]{12}(?:[0-9]{3})?$/.test(number)) { // Visa
return {
issuer : 'Visa',
cidLength : 3,
length : 16
};
} else if (/^5[1-5][0-9]{14}$/.test(number)) { // MasterCard
return {
@SeanJM
SeanJM / react-scroll-lock-mixin.js
Last active August 28, 2017 20:29
A mixin to lock the scrolling of a component's parents for react
// Based on https://codepen.io/somethingkindawierd/post/react-mixin-scroll-lock
// How this works is that it will lock the scroll of the component parents
// and allow the current element to scroll
import ReactDOM from "react-dom";
const ScrollLockMixin = {
scrollLock: function (scrollElement) {
let p;
this.scrollElement = scrollElement || ReactDOM.findDOMNode(this);
@SeanJM
SeanJM / math.js
Last active November 14, 2017 19:58 — forked from FrankFang/math.js
Handlebars Math.
const handlebars = require("handlebars");
const operators = {
"+": (a, b) => a + b,
"-": (a, b) => a - b,
"*": (a, b) => a * b,
"/": (a, b) => a / b,
"%": (a, b) => a % b
};
handlebars.registerHelper("math", function (a, op, b) {