This file contains 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
if (pesq.vazio()) { | |
} else { | |
sql = "WHERE descricao LIKE '%" + pesq.palavras() + "%'"; | |
} |
This file contains 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
public class Util { | |
public static String cotoiso(String s) { | |
return s.split("/")[2] + "-" + s.split("/")[1] + "-" + s.split("/")[0]; | |
} | |
public static String fn(int n, int c) { | |
if (n < 10) { | |
String r = ""; | |
for (int i = 0; i < c - 1; i++) { |
This file contains 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
// considere que o mysql está instalado na máquina local e temos as credenciais, | |
// então estabelecemos uma conexão | |
$con = mysql_connect("localhost","admin","senhasecreta"); | |
// considere que tenhamos uma base de dados chamada "agenda", então a selecionamos | |
mysql_select_db("agenda", $con); | |
// considere que tenhamos uma tabela chamada contatos com os campos nome e telefone, | |
// então inserimos um registro | |
$ok = mysql_query("INSERT INTO contatos (nome, telefone) VALUES ('$contato->nome', '$contato->telefone')"); |
This file contains 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
$colunaDifetente = $_SESSION['janelaBusca'][$_POST['idJanela']]['colunaDiferente']; | |
if(is_array($colunaDifetente)){ | |
if (is_array($vet)){ | |
foreach ($vet as $k=>$v){ | |
foreach ($v as $k1=>$v1){ | |
foreach ($v1 as $k2=>$v2){ | |
foreach ($colunaDifetente as $k3=>$v3){ | |
if ($vet[$k]['r'][$k2]['c'] == $k3) { | |
$vet[$k]['r'][$k2]['c'] = $v3; |
This file contains 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 | |
if ($numero_nota >= 1 && $numero_nota < 10) { | |
$numero_nota = '00000000' . $numero_nota; | |
} else if ($numero_nota >= 10 && $numero_nota < 100) { | |
$numero_nota = '0000000' . $numero_nota; | |
} else if ($numero_nota >= 100 && $numero_nota < 1000) { | |
$numero_nota = '000000' . $numero_nota; | |
} else if ($numero_nota >= 1000 && $numero_nota < 10000) { | |
$numero_nota = '00000' . $numero_nota; | |
} else if ($numero_nota >= 10000 && $numero_nota < 100000) { |
This file contains 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
def impares(max = 2^16-1): | |
for n in range(max): | |
if n % 2 == 1: | |
print 'gerando ...' | |
yield n | |
# situação de uso: | |
for n in impares(10): | |
print 'percorrendo ...' |
This file contains 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
def caminhoPao(separador, nivel1, *demaisNiveis): | |
caminho = [nivel1] | |
caminho.extend(demaisNiveis) | |
return " > ".join(caminho) | |
print caminhoPao(">") # este falha, o primeiro nivel eh obrigatorio | |
print caminhoPao(">", "Home") | |
print caminhoPao(">", "Home", "Eletronicos", "TV's", "LED") |
This file contains 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
class Dinheiro { | |
private String simbolo; | |
private String nome; | |
private int inteiro; | |
private int decimal; | |
public Dinheiro(String simbolo, String nome, int inteiro, int decimal) { | |
if (inteiro < 0) { |
This file contains 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
/** | |
* Lida com todas as atividades relacionadas ao movimento fiscal e contábil | |
* | |
* @author Márcio Torres | |
* @version 1.0 | |
* | |
*/ | |
class Contabil { | |
/** |
This file contains 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
class Cliente { | |
int codigo; // código do cliente | |
String nome; // nome do cliente | |
// construtor padrão | |
public Cliente() { | |
} | |
// ... |