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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<script type="text/javascript"> | |
//Armazena dados no banco de dados do navegador | |
//Pega uma referência de localStorage (no objeto window) | |
var db = window.localStorage; |
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 | |
//Content-Type do tipo stream | |
header('Content-Type: text/event-stream'); | |
//Sem cash | |
header('Cache-Control: no-cache'); | |
//Inicia uma função | |
function send_msg($msg) { | |
//Envia um json | |
echo 'data:'.json_encode(array('id' => rand(0,100), 'msg' => $msg)); | |
//Descarrega o buffer de saída |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<!-- jquery CDN --> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"> | |
</script> | |
<script type="text/javascript"> | |
$(function(){ | |
//Verifica se temos acesso ao recurso |
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
#Armamentos/Armamento.php | |
<?php | |
//Qualquer tipo de arma deve implementar armamento | |
interface Armamento{ | |
//Deve obrigatoriamente poder ser utilizada | |
public function usar(); | |
} | |
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 | |
//(Variáveis Variantes)Não é só o conteúdo da variável que pode mudar mas também seu nome | |
$variavel = 'nome'; | |
// $$ Cria uma nova variável representada pelo contéudo de $variavel | |
$$variavel = '@auhtor: Tiago Davi'; | |
//=> @auhtor: Tiago Davi | |
echo $nome.'<br>'; | |
$frameworks = array( | |
'codeigniter' => 'leve, simples, flexível e baixa curva de aprendizado', |
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 | |
//mdc (PHP 5.3) | |
$mdc = function($x,$y) use (&$mdc){ | |
$a = max($x,$y); | |
$b = min($x,$y); | |
return ($a%$b == 0) ? ($b) : ($mdc($b,($a%$b))); | |
}; | |
//mmc (PHP 5.3) |
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 | |
/* | |
@author: Tiago Davi | |
@blog: tiagodavi.blogspot.com | |
//fonte : somatematica.com.br | |
CÁLCULO DO M.D.C. PELO PROCESSO DAS DIVISÕES SUCESSIVAS | |
Regra prática: | |
1º) dividimos o número maior pelo número menor; | |
48 / 30 = 1 (com resto 18) |
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 | |
//Função recursiva que calcula o fatorial de um número | |
function fatorial($numero){ | |
if($numero <= 1){ | |
return $numero; | |
}else{ | |
return $numero * fatorial($numero - 1); | |
} | |
} |
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
//Exemplo de for super legal utilizando Scala | |
object Laco{ | |
//main (um pouquinho diferente do java) | |
def main(args: Array[String]){ | |
for{ | |
/* | |
Para cada 5 incrementos em i vai haver 1 incremento em j | |
Quando i chegar a 5 vai resetar seu contador para 1 e j vai incrementar para 2 | |
E assim sucessivamente... ate j chegar a 5 | |
*/ |