Skip to content

Instantly share code, notes, and snippets.

Working from home

Leo Dutra leodutra

Working from home
View GitHub Profile
View Liberal Regex Pattern for Web URLs
The regex patterns in this gist are intended only to match web URLs -- http,
https, and naked domains like "". For a pattern that attempts to
match all URLs, regardless of protocol, see:
# Single-line version:
View Liberal Regex Pattern for All URLs
The regex patterns in this gist are intended to match any URLs,
including "", "x-whatever://foo", etc. For a
pattern that attempts only to match web URLs (http, https), see:
# Single-line version of pattern:
leodutra / iframe-reference.html
Last active Aug 29, 2015
IFrame Default Attributes Reference + Scroll Definition (IE 8- Fix)
View iframe-reference.html
seamless="seamless" - Specifies that the <iframe> should look like it is a part of the containing document
allowTransparency="true" - old "seamless" alternative (is not a W3C spec/ option)
frameborder="0" - no border on old browsers (deprecated on HTML5)
scrolling="auto" - Specifies whether or not to display scrollbars in an <iframe> (deprecated on HTML5)
horizontalscrolling - force hide horizontal scrolling on (IE fix)
verticalscrolling - force hide vertical scrolling on (IE fix)
View is-document-hidden.js
function getHiddenProp(){
var prefixes = ['webkit','moz','ms','o'];
// if 'hidden' is natively supported just return it
if ('hidden' in document) return 'hidden';
// otherwise loop over all the known prefixes until we find one
for (var i = 0; i < prefixes.length; i++){
if ((prefixes[i] + 'Hidden') in document)
return prefixes[i] + 'Hidden';
leodutra / fullEncodeURI.js
Last active Aug 29, 2015
Fully Encode URI/URL
View fullEncodeURI.js
function fullEncodeURI(str) {
if (str !== undefined && str !== null) {
str = '' + str;
var res = '';
for(var i = 0, l = str.length; i < l ;) {
res += '%';
res += str.charCodeAt(i++).toString('16');
return res;
leodutra / node-with-proxy-config.bat
Last active Aug 29, 2015
Configurar Node.js em rede privada com Squid Proxy
View node-with-proxy-config.bat
@echo off
set proxy=
set loglevel=http
:: Intro
echo Configuracao NODE JS & echo.
echo Entre com o login de rede. & echo.
leodutra / load-template.js
Last active Aug 29, 2015
Loads an external HTML template inside a script tag.
View load-template.js
(function($) {
// <script type="text/x-html-template" data-src="url" async></script>
$("script[type='text/x-html-template']").each(function() {
var $el = $(this);
var src = $'src');
if (!src) return;
url: src,
leodutra / decodeURIComponent.js
Created Oct 6, 2014
Cross compatible decodeURIComponent()
View decodeURIComponent.js
// about it:
// Some Mozilla browsers do wrong conversion
decodeURIComponent(str.replace(/\+/gim,' '));
leodutra / test-title-attr-line-break.html
Created Nov 17, 2014
Test - Breaking Line Inside Title Attribute
View test-title-attr-line-break.html
<!DOCTYPE html>
<title>TEST - Line Break in title attribute</title>
.line-through {
text-decoration: line-through;
leodutra / extends.js
Last active Aug 29, 2015
JavaScript simple inheritance.
View extends.js
function EXTENDS(super_, extension) {
var obj = function() {};
var proto = obj.prototype = new super_();
proto.super = function() {
super_.apply(this, arguments);
for (var prop in extension) {