This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var filename = 'github.txt'; | |
var extension = filename.split('.').pop(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
addEventListener("click", function(){ | |
var el = document.documentElement; | |
var rfs = el.requestFullScreen || el.webkitRequestFullScreen || el.mozRequestFullScreen; | |
rfs.call(el); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.all('/path/to/api/*', function xhrOnly(req, res, next) { | |
if (req.xhr) next(); | |
else res.send(403, 'XHR requests only, please'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Math.random().toString(36).substr(2,16); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> | |
<style type="text/css"> | |
iframe#meuhtml{width:100%;border:0;} | |
</style> | |
<iframe src="about:blank" id="meuhtml"></iframe> | |
<?php | |
$html = "<h1>Atenção!</h1>\n<p>Texto com ' aspas simples</p>"; | |
$html = str_replace(array("'", "\n"), array("\\'", "\\n"), $html); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
date_default_timezone_set('America/Sao_Paulo'); | |
/** | |
* Classe com filtros mágicos sobre as propriedades | |
*/ | |
abstract class Magic { | |
/** @var array Propriedades */ | |
private $_properties; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function toCamelCase(str) { | |
return str.toLowerCase().replace(/(?:(^.)|(\s+.))/g, function(match) { | |
return match.charAt(match.length-1).toUpperCase(); | |
}); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Detecta encoding de uma string, testando as opções informadas | |
* @param string $string | |
* @param array $opcoes | |
* @return string|null | |
*/ | |
function obtemEncoding($string, $opcoes=array('UTF-8', 'ISO-8859-1', 'WINDOWS-1251')) | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Extrai e-mails de uma string, no padrão usado na estrutura de mensagens | |
* @param string $str | |
* @return array | |
*/ | |
function emailsFromStr($str) | |
{ | |
preg_match_all('/<([^>]*)>/', $str, $matches); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function verificadorDe($tipo){ | |
return function($var) use($tipo) { | |
return gettype($var) == $tipo; | |
} | |
} | |
$verificaInteiro = verificadorDe('integer'); | |
$verificaTexto = verificadorDe('string'); |
OlderNewer