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 | |
$data = $_SERVER['REQUEST_METHOD'] == "POST" ? $_POST : $_GET; | |
$option = $data["opc"]; | |
switch($option){ | |
case "inserir": | |
$sql = "INSERT INTO tabela (campoA, campoB, campoC, campoN) VALUES (?, ?, ?, ?)"; | |
//código para processar os dados enviados do front, e presentes na $data. |
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
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Editar Nota</title> | |
<meta http-equiv="content-Type" content="text/html" charset="UTF-8"/> | |
<link rel="shortcut icon" href="img/icon.png"/> | |
<link rel="stylesheet" type="text/css" href="css/estilo.css"/> | |
<!-- Bootstrap CSS --> | |
<link rel="stylesheet" type="text/css" href="./css/bootstrap.min.css"> |
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 static string Parse(this DbEntityValidationException e) | |
{ | |
var builder = new StringBuilder(); | |
foreach (var eve in e.EntityValidationErrors) | |
{ | |
builder.AppendFormat("Entity type: {0} | State: {1}",eve.Entry.Entity.GetType().Name,eve.Entry.State); | |
foreach (var ve in eve.ValidationErrors) | |
builder.AppendFormat("Property name: {0} | Current value: {1} | Error message: {2}", | |
ve.PropertyName, | |
eve.Entry.CurrentValues.GetValue<Object>(ve.PropertyName), |
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 | |
session_start(); | |
//seu código de verificar usuário... | |
//... | |
//... | |
//... | |
$_SESSION['email'] = $code; | |
$_SESSION['nome'] = $nome; |
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 | |
$texto = "sua string de 1500 caracteres"; | |
$limite = 5; //troca para 500, fiz 5 só pra teste. | |
$banner = "<img src='https://via.placeholder.com/50' alt='teste'/>"; //troca pelo seu código de banner. | |
$result = ""; | |
$splits = strlen($texto) % $limite; | |
for($i=0;$i<$splits;$i++) | |
$result .= substr($texto, $i * $limite, $limite) . $banner; | |
echo $result; |
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
function parseCSV(data, separator) { | |
const lines = data.split(/\r\n|\n/); | |
const header = lines[0].split(separator); | |
const result = []; | |
for(let i = 1; i < lines.length; i++){ | |
const fields = lines[i].split(separator); | |
const line = {}; | |
for(let k = 0; k < header.length; k++) | |
line[header[k]] = fields[k]; |
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
function Custo(valor, nome){ | |
this.valor = valor; | |
this.nome = nome; | |
} | |
Custo.prototype.juros = function(juros) { | |
//isso tá errado, pq isso não é juros né... | |
this.valor += juros; | |
return this.valor; | |
} |
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 | |
$urlX = "https://jsonplaceholder.typicode.com/todos/"; //URL1 que retorna X | |
$urlY = "https://jsonplaceholder.typicode.com/users"; //URL2 que retorna Y | |
$multiHandler = curl_multi_init(); | |
//URL1 - X | |
$curlX = curl_init(); | |
curl_setopt($curlX, CURLOPT_URL, $urlX); | |
curl_setopt($curlX, CURLOPT_HEADER, 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
<?php | |
function myCount($array){ | |
global $chamadas; | |
if($chamadas == 0) | |
echo "<i>Primeira chamada da função <b>myCount</b>!</i> <br />"; | |
else | |
echo "Chamei a função <b>myCount</b> de novo! <b>Isso é um problema</b>...<br />"; | |
$chamadas++; | |
return count($array); |
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
using System; | |
namespace MailCleaner | |
{ | |
using Pop3; | |
using System.Collections.Generic; | |
using System.IO; | |
using System.Linq; | |
using System.Text; | |
using System.Text.RegularExpressions; |