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
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
@fhferreira
fhferreira / chart-responsivo.js
Created May 28, 2019 18:01 — forked from marpontes/chart-responsivo.js
Habilitando os gráficos do CDE a responderem a mudanças de layout.
/* [Dashboards compatíveis com requirejs]
Solução componente a componente
--------------------------------------------------------------------
Colocar no Post Execution:
*/
function(){
var comp = this, elm = $("#"+comp.htmlObject);
$(window).resize(function(){
comp.chart.options.width = elm.width();
comp.chart.render(/*bypassAnimation*/true, /*recreate*/true, /*reload*/false);
@fhferreira
fhferreira / link-between-messengers.php
Created May 20, 2019 23:16 — forked from mpociot/link-between-messengers.php
Use BotMan to link between multiple messenger services
@fhferreira
fhferreira / slugify.js
Created May 1, 2019 06:56 — forked from gabrielfroes/slugify.js
Javascript Slugify
/*
Create SLUG from a string
This function rewrite the string prototype and also
replace latin and other special characters.
Forked by Gabriel Froes - https://gist.github.com/gabrielfroes
Original Author: Mathew Byrne - https://gist.github.com/mathewbyrne/1280286
*/
if (!String.prototype.slugify) {
String.prototype.slugify = function () {
@fhferreira
fhferreira / checkbox.blade.php
Created March 23, 2019 19:40 — forked from skadimoolam/checkbox.blade.php
Customizable form partials for Laravel - https://laravelcollections.com
@php
$d = $d ?? null; // default value
@endphp
<div class="form-group row">
<label for="{{ $n }}" class="col-sm-4 col-form-label text-md-right"><b>{{ $l }}</b></label>
<div class="col-md-8">
<input id="{{ $n }}" type="checkbox" class="form-control" name="{{ $n }}" value="1" @if(old($n, $d) == '1') checked @endif>
@if ($errors->has($n))
<small class="text-danger">{{ $errors->first($n) }}</small>
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');
@fhferreira
fhferreira / ddd_cqrs_event-sourcing_in_php.md
Created February 13, 2019 05:00 — forked from jsor/ddd_cqrs_event-sourcing_in_php.md
DDD, CQRS and Event Sourcing in PHP

DDD, CQRS and Event Sourcing in PHP

  • Broadway - Infrastructure and testing helpers for creating CQRS and event sourced applications
  • EventCentric.Core - Event Sourcing and CQRS in PHP
  • LiteCQRS - Small convention based CQRS library for PHP
  • predaddy - Common DDD classes including an annotation driven message bus and tools for CQRS and Event Sourcing
  • ProophEventSourcing - Provides basic functionality for event-sourced aggregates
  • ProophEventStore - PHP 5.4+ EventStore Implementation
  • ProophServiceBus - PHP Enterprise Service Bus Implementation supporting CQRS and DDD
@fhferreira
fhferreira / laravel_facades.md
Created February 5, 2019 21:32 — forked from poing/laravel_facades.md
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.

@fhferreira
fhferreira / Kernel.php
Created December 19, 2018 18:02 — forked from ivanvermeyen/Kernel.php
Find any running "queue:listen" processes for a Laravel project and kill those. Fire "php artisan queue:stop" in your "current" project root. Intended to use with a deploy script when you are using non-daemon listeners and deploy releases. If you are using daemons, run "queue:restart" instead. You can use a process monitoring tool like Superviso…
<?php
namespace App\Console;
use App\Console\Commands\StopQueueListeners;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
class Kernel extends ConsoleKernel
{
@fhferreira
fhferreira / google direction.js
Created November 15, 2018 21:43
google direction
var maps = require("@google/maps");
var client = maps.createClient({
key: "AIzaSyCSA6hgjkJhkvwO7OP9dG230uEP0ryFXns"
});
function generateDateTime(hour, minutes) {
var d = new Date();
d.setHours(hour,minutes,0,0);
d.setDate(d.getDate() + 1);