Skip to content

Instantly share code, notes, and snippets.

View benjamincharity's full-sized avatar
🤖

Benjamin Charity benjamincharity

🤖
View GitHub Profile
@deadkarma
deadkarma / gist:1561438
Created January 4, 2012 18:51
get credit card type
function GetCreditCardTypeByNumber(ccnumber) {
var cc = (ccnumber + '').replace(/\s/g, ''); //remove space
if ((/^(34|37)/).test(cc) && cc.length == 15) {
return 'AMEX'; //AMEX begins with 34 or 37, and length is 15.
} else if ((/^(51|52|53|54|55)/).test(cc) && cc.length == 16) {
return 'MasterCard'; //MasterCard beigins with 51-55, and length is 16.
} else if ((/^(4)/).test(cc) && (cc.length == 13 || cc.length == 16)) {
return 'Visa'; //VISA begins with 4, and length is 13 or 16.
} else if ((/^(300|301|302|303|304|305|36|38)/).test(cc) && cc.length == 14) {
@keithchu
keithchu / fixorientationzoom.js
Created January 6, 2012 00:49 — forked from scottjehl/fixorientationzoom.js
Fix iOS Orientation Change Zoom Bug
/*
An attempt at fixing the dreaded iOS orientationchange zoom bug http://adactio.com/journal/5088/. Seems to work!
Authored by @scottjehl
MIT License.
*/
(function(w){
var doc = w.document;
if( !doc.querySelectorAll ){ return; }
@benjamincharity
benjamincharity / customTransition.css
Last active December 12, 2015 03:38
Humanistic CSS Transition
-webkit-transition: all 300ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
-moz-transition: all 300ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
-ms-transition: all 300ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
-o-transition: all 300ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
transition: all 300ms cubic-bezier(0.26, 0.86, 0.44, 0.985);
# Grep for the phrase 'TODO' in SCSS files (simply omit everything
# after the last star to search all file types. The 'j' option stops
# the cursor from automatically jumping to the first instance.
:vimgrep TODO/j **/*.scss
# Open a pane showing all instances.
:cw
@benjamincharity
benjamincharity / findUnicodeCharacter.js
Created June 26, 2013 13:03
Get the unicode character with Javascript.
// From http://blog.hull.io/post/46243434040/introducing-sass-getunicode
'☃'.charCodeAt(0).toString(16);
@benjamincharity
benjamincharity / phoneInput.directive.js
Last active February 10, 2016 13:09
Keep a phone number within an input formatted while keeping the model clean with only numbers
export function PhoneInputDirective(
$filter, $browser, $timeout
) {
'ngInject';
const directive = {
restrict: 'A',
scope: {
phoneInput: '=',
},
@adamreisnz
adamreisnz / Setup GitHub issue labels script
Last active November 17, 2016 14:38 — forked from hubertursua/setup github issues labels.sh
A terminal script to setup GitHub issue labels for a project.
Setup GitHub issue labels script
@benjamincharity
benjamincharity / githubcliauthissues
Last active May 15, 2017 20:16
Fix the github auth issue where it asks for permissions every push/pull.
// Step 1.
// this returns some useful information which will help you fill out the next command.
// look for the line that begins with "remote.origin.url".
$ git config -l
// Step 2.
// use the information from step one to replace 'your_username' and 'your_project'.
$ git config remote.origin.url git@github.com:your_username/your_project.git
@ericdouglas
ericdouglas / embed-plunker.html
Created December 6, 2014 13:31
Embed Plunker
<iframe style="width: 100%; height: 600px" src="http://embed.plnkr.co/GvOO1itX8MG7zJLywSN8" frameborder="0" allowfullscren="allowfullscren"></iframe>
@jlittlejohn
jlittlejohn / JS Hide Address Bar for iOS Android
Last active May 1, 2019 15:54
JS: Hide Address Bar for iOS & Android
/*
* Normalized hide address bar for iOS & Android
* (c) Scott Jehl, scottjehl.com
* MIT License
*/
(function( win ){
var doc = win.document;
// If there's a hash, or addEventListener is undefined, stop here
if( !location.hash && win.addEventListener ){