Skip to content

Instantly share code, notes, and snippets.

View arakno's full-sized avatar

Paulo arakno

View GitHub Profile
@arakno
arakno / useful regex
Created October 27, 2014 16:05
useful regex
var EmailRegex = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
//simple email [a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&amp;'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?
var FilenameRegex = /^[0-9a-zA-Z\^\&\'\£\@\;\{\}\[\]\,\”\`\’\$\=\!\-\#\(\)\.\%\+\~\_ ]+$/;
var URLRegex = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
var TelRegex = /^(?:(?:\(?(?:00|\+)([1-4]\d\d|[1-9]\d?)\)?)?[\-\.\ \\\/]?)?((?:\(?\d{1,}\)?[\-\.\ \\\/]?){0,})(?:[\-\.\ \\\/]?(?:#|ext\.?|extension|x)[\-\.\ \\\/]?(\d+))?$/i;
//simple Tel ^([0-9\(\)\/\+ \-]*)$
@arakno
arakno / mp4 test
Created October 29, 2014 12:15
feature detect video capabilities
if (Modernizr.video.h264 == "" || Modernizr.video.h264 == "maybe" || Modernizr.video.h264 == undefined || v.currentSrc == "" || !v.canPlayType || !v.canPlayType('video/mp4') ) {
//... magic happens
}
@arakno
arakno / gist:88c188988601570748c5
Created February 6, 2015 11:33
detect mobile browser obj
var isMobile = {
Android: function() { return navigator.userAgent.match(/Android/i); },
BlackBerry: function() { return navigator.userAgent.match(/BlackBerry/i); },
iOS: function() { return navigator.userAgent.match(/iPhone|iPad|iPod/i); },
Opera: function() { return navigator.userAgent.match(/Opera Mini/i); },
Windows: function() { return navigator.userAgent.match(/IEMobile/i); },
any: function() { return (isMobile.Android() || isMobile.BlackBerry() || isMobile.iOS() || isMobile.Opera() || isMobile.Windows()); } };
@arakno
arakno / gist:8f1841744ee9240cd9ba
Created February 6, 2015 12:08
mobile browser UA/feature detection sniffing
var ua = navigator.userAgent.toLowerCase(),
isOpera = !!window.opera || ua.indexOf(' opr/') >= 0,
isChrome = !!window.chrome && !isOpera,
isAndroid = ua.indexOf("android") > -1,
iOS = /(ipad|iphone|ipod)/g.test(ua),
isHandheld = window.matchMedia && window.matchMedia('(max-device-width: 960px)').matches || screen.width <= 960,
isTouchDevice = 'ontouchstart' in window || 'onmsgesturechange' in window,
isMobile = (isHandheld && isTouchDevice) && (isAndroid || iOS);
function isMobile () {
var isMobile;
if(/(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|ipad|iris|kindle|Android|Silk|lge |maemo|midp|mmp|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino/i.test(navigator.userAgent)
|| /1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a wa|abac|ac(er|oo|s\-)|ai(ko|rn)|al(av|ca|co)|amoi|an(ex|ny|yw)|aptu|ar(ch|go)|as(te|us)|attw|au(di|\-m|r |s )|avan|be(ck|ll|nq)|bi(lb|rd)|bl(ac|az)|br(e|v)w|bumb|bw\-(n|u)|c55\/|capi|ccwa|cdm\-|cell|chtm|cldc|cmd\-|co(mp|nd)|craw|da(it|ll|ng)|dbte|dc\-s|devi|dica|dmob|do(c|p)o|ds(12|\-d)|el(49|ai)|em(l2|ul)|er(ic|k0)|esl8|ez([4-7]0|os|wa|ze)|fetc|fly(\-|_)|g1 u|g560|gene|gf\-5|g\-mo|go(\.w|od)|gr(ad|un)|haie|hcit|hd\-(m|p|t)|hei\-|hi(pt|ta)|hp( i|ip)|hs\-c|ht(c(\-| |_|a|g|p|s|t)|tp)|hu(aw|tc)|i\-(20|go|ma)|i230|iac( |\-|\/)|ibro|idea|ig01|ikom|im1k|inno|ipaq
@arakno
arakno / jquery.mobile.just-touch.js
Created March 18, 2016 11:53
fork that works with jquery 1.9
// This is a combination of two modified files from jQuery Mobile,
// jquery.mobile.vmouse.js and jquery.mobile.event.js
// They were modified to only provide the touch event shortcuts, and
// avoid the rest of the jQuery Mobile framework.
// The normal jQuery Mobile license applies. http://jquery.org/license
//
// This plugin is an experiment for abstracting away the touch and mouse
// events so that developers don't have to worry about which method of input
// the device their document is loaded on supports.
//
@arakno
arakno / detect iOS
Created March 21, 2016 10:29
detect iOS
instance.detectiOS = function () {
return /iPad|iPhone|iPod/.test(navigator.userAgent) && !window.MSStream;
};
// Place your key bindings in this file to overwrite the defaults
[
{
"key": "ctrl+f5",
"command": "workbench.action.reloadWindow",
"when": "editorTextFocus"
},
{
"key": "ctrl+a",
"command": "editor.action.selectAll",
@arakno
arakno / Object.watch.js
Last active September 13, 2018 20:31
Object watch polyfill
/*
* object.watch polyfill
*
* 2012-04-03
*
* By Eli Grey, http://eligrey.com
* Public Domain.
* NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.
*/
@arakno
arakno / .gitignore
Last active November 7, 2019 11:43
node_modules
bower_components
.DS_Store
.idea
bundle.*
npm-debug.log
debug.log
build
main.js
.tmp