Skip to content

Instantly share code, notes, and snippets.

💻
Typing..

Ivan Augusto ivanaugustobd

💻
Typing..
Block or report user

Report or block ivanaugustobd

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View php_var_parse_benchmark.php
<?php
$runBench = function ($val, Closure $callable, string $using) : array {
$startTime = microtime(true);
for ($i = 0; $i < 1000000; $i++) {
$callable($val);
}
$elapsedTime = microtime(true) - $startTime;
View CustomersController.php
<?php
class CustomersController extends Controller
{
public function store(CustomerFormRequest $request)
{
$customer = Customer::create($request->input());
return redirect(route('customers.show', $customer->id));
}
}
View CustomersControllerTest.php
<?php
use App\Htpp\Controllers\CustomersController;
class CustomersControllerTest extends TestCase
{
public function testCustomerRegister()
{
// Simulando os dados necessários
$formData = [
View header.scss
.header {
@media #{$mobile} {
grid-template-areas: 'logo cart' 'search search' 'links links' 'categories categories';
grid-template-columns: 1fr auto;
}
}
View header.html
<header class="header">
<div class="header__logo-wrapper">[..]</div>
<div class="header__search">[..]</div>
<div class="header__links">[..]</div>
<div class="header__cart">[..]</div>
<div class="header__categories-wrapper">[..]</div>
</header>
View item.html
<li class="products-grid-item">
<img class="products-grid-item__image">
<div class="products-grid-item__description">[..]</div>
<span class="products-grid-item__price">[..]</span>
<button class="button button - buy">[..]</button>
</li>
View product_grid.scss
.products-grid {
display: grid;
grid-gap: 15px;
grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); // distribui os itens e já deixa a grade responsiva
}
View submitFormWithCallback.js
const submitForm = (form, callback = null) => {
// [..]
fetch(form.action, [..])
.then(response => {
// [..]
if (callback) {
callback(response) // executa a função personalizada que varia pra cada form, passando a response pra ela
}
})
View submitForm.js
const submitForm = form => {
// se quiser colocar um efeito de loading, ele vai aqui
const previousMessage = form.querySelector('.message')
if (previousMessage) {
form.removeChild(previousMessage) // remove a mensagem de algum submit anterior
}
const body = new FormData(form) // coloca os inputs/select/textarea do form numa variável
const method = form.method // pega o método do form (GET/POST)
View contact_form.html
<form type="post" action="/customer/account/registerPost">
<input type="hidde" name="csrf_key" value="123456">
<label for="name">Nome:</label>
<input type="text" name="name" id="name">
<label for="email">E-mail:</label>
<input type="text" name="email" id="email">
<label for="message">Mensagem:</label>
You can’t perform that action at this time.