Skip to content

Instantly share code, notes, and snippets.

View fhferreira's full-sized avatar
🏠
Home-Office since 2005

Flávio H. Ferreira fhferreira

🏠
Home-Office since 2005
View GitHub Profile
#!/usr/bin/env php
<?php
declare(strict_types=1);
namespace WaitForElasticsearch;
use InvalidArgumentException;
use UnexpectedValueException;
use function curl_close;
@mtvbrianking
mtvbrianking / laravel eloquent query debug.md
Last active April 20, 2024 16:29
Laravel debug (dump) database queries

Laravel debug database queries

Raw SQL

SELECT
  users.name AS staff,
  facilities.name AS facility
FROM
  users
@hmaesta
hmaesta / appmax-upsell.php
Created September 27, 2019 17:40
Como configurar uma página de upsell usando Appmax
<?php
/**
* Antes de começar, adicione as possibilidades de
* upsell pela página: https://admin.appmax.com.br/my-upsell
*
* No campo "URL página de Upsell" preencha sua
* URL no formato: site.com.br/este-arquivo.php?order_bundle_id={order_bundle_id}
*
* Obviamente você pode colocar outros parâmetros,
* mas seguindo este modelo é obrigatório configurar
@matheusgontijo
matheusgontijo / magento-2-debugging-tricks-mysql-query-fetchall-fetchrow-data-hydrate-and-xdebug.php
Created June 10, 2019 01:00
Magento 2 Debugging Tricks - MySQL Query, fetchAll, fetchRow, Data Hydrate & PHP xDebug by Matheus Gontijo
Magento 2 Debugging Tricks - MySQL Query, fetchAll, fetchRow, Data Hydrate & PHP xDebug by Matheus Gontijo
Video: https://www.youtube.com/watch?v=xLf3OwpAFhQ
-----------------------------------------------
1) Track MySQL queries
vendor/magento/zendframework1/library/Zend/Db/Adapter/Abstract.php::query
vendor/magento/zendframework1/library/Zend/Db/Select.php
<?php
// php cluter-quick-check --host <host> --port <port> [--auth password]
function panicAbort($str_msg) {
fprintf(STDERR, "Error: $str_msg\n\n");
$bt = debug_backtrace();
fprintf(STDERR, "--- BACKTRACE ---\n");
foreach (debug_backtrace() as $frame => $frame_info) {
@Pen-y-Fan
Pen-y-Fan / Test Driven Development (TDD) Learning Plan.md
Last active April 25, 2024 16:28
Test Driven Development (TDD)

Learning Plan for Test Driven Development (TDD)

These learning resources primarily focus on Test Driven Development (TDD).

  • There is an emphasis on learning using PHP, Laravel and PHPUnit.
  • All these resources are free (at the time of writing)
public function index(Request $request)
{
$sortBy = 'id';
$orderBy = 'desc';
$perPage = 20;
$q = null;
if ($request->has('orderBy')) $orderBy = $request->query('orderBy');
if ($request->has('sortBy')) $sortBy = $request->query('sortBy');
if ($request->has('perPage')) $perPage = $request->query('perPage');
@leocavalcante
leocavalcante / watch.php
Created February 21, 2019 20:45
Watch script for Swoole HTTP server restarts.
<?php declare(strict_types=1);
require_once __DIR__.'/vendor/autoload.php';
use Symfony\Component\Process\Process;
$process = new Process(['php', 'index.php']);
echo "Starting process\n";
$process->start();
@sanjukurian
sanjukurian / bitcoin.js
Created January 31, 2019 07:14
create bitcoin wallet, make a transaction on bitcoin network using bitcoinjs-lib and blockcypher
var request = require('request');
const bitcoin = require('bitcoinjs-lib');
var buffer = require('buffer');
const bitcoinNetwork = bitcoin.networks.testnet;
var rootUrl = "https://api.blockcypher.com/v1/btc/test3";
//create wallets
const TestNet = bitcoin.networks.testnet3;
@poing
poing / laravel_facades.md
Last active March 25, 2024 21:37
Laravel Facades

Understanding Facades in Laravel

What's a Facade?

The Laravel explination, shown below is confusing.

Facades provide a "static" interface to classes that are available in the application's service container. Laravel ships with many facades which provide access to almost all of Laravel's features. Laravel facades serve as "static proxies" to underlying classes in the service container, providing the benefit of a terse, expressive syntax while maintaining more testability and flexibility than traditional static methods.

Many examples use Cache::get('key') to demonstrate how a Facade works. Comparing the following code to the utility that a Facade provides.