Skip to content

Instantly share code, notes, and snippets.

View mknparreira's full-sized avatar

Maikon Parreira mknparreira

View GitHub Profile
@mknparreira
mknparreira / php-phpstorm-shortcurts.md
Last active August 12, 2021 22:28
PHP | PHPStorm Shortcurts

PHP Storm Shortcurts

  • CTRL + N You will let you instantly move to any part of any class or file in your project.

  • CTRL + W Select parts of code by context aware. For instance: if the cursor were in the method, all entire content will be selected.

  • CTRL + ALT + L One of my most used keyboard combos, will immediately format your code according to the preferred style guidelines

@mknparreira
mknparreira / laravel-creating-own-laravel-directives.md
Last active August 12, 2021 22:28
Laravel | Creating own Laravel directives

Laravel Directives

This is a example to create a personal laravel directive

use Illuminate\View\Compilers\BladeCompiler;

protected function registerBladeExtensions()
    {
        $this->app->afterResolving('blade.compiler', function (BladeCompiler $bladeCompiler) {
            $bladeCompiler->if('canActAsTgo', function ($permission_user) {
@mknparreira
mknparreira / postegre-sql-regex.md
Last active August 12, 2021 22:27
PostegreSQL | Just a simple REGEX

SQL REGEX

SELECT *
FROM tasks
WHERE `dependency` REGEXP 's:[0-9]+:".*33.*".*'
@mknparreira
mknparreira / postegre-sql-with-max-and-count.md
Last active August 12, 2021 22:27
PostegreSQL | An example of subquery with COUNT() and MAX()
SELECT 
	lab1.product_name,
	COUNT("*") AS total_users
FROM
    (
	SELECT
		GROUP_CONCAT(lab2.plant_profile_id) AS teste,
		substring_index(group_concat(lab2.plant_profile_id SEPARATOR ','), ',', 1) as plant_id,
		substring_index(group_concat(lab2.product_name SEPARATOR ','), ',', 1) as product_name,
@mknparreira
mknparreira / others-error-105.md
Last active August 12, 2021 22:26
Others | Resolver problema de DNS ou ERROR 105 que não deixava abrir o GDrive
@mknparreira
mknparreira / terminal-try-to-solve-ip-problems.md
Last active August 12, 2021 22:26
Terminal | Try to solve IP Problems

IP Problems

  netsh interface ipv6 reset
  netsh interface ipv4 reset

Ou Vá em Configurações de proxy automática e desative-o

@mknparreira
mknparreira / php-bug-fix-which-does-not-allows-display-images-inside-pdf-using-dompdf-package.md
Last active August 12, 2021 22:25
PHP | How to fix a bug which does not allows display images inside PDF using dompdf package

Introduction

We are using a package to create and make pdf download called Dompdf (https://github.com/barryvdh/laravel-dompdf).

In some time, we needed to display the company image logo inside pdf report. we did everything we could and it did not working.
In the other words, convert image to base64.

File: PdfController.php

Make sure that option "isPhpEnabled" is true

@mknparreira
mknparreira / php-phpunit-visual-studio-code-windows.md
Last active August 12, 2021 22:25
PHP | How to configurate PHPUnit to Visual Studio Code for Windows

Step I

Open the settings.json file and put it on this following configuration:

{
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  "phpunit.php": "C:\\xampp\\php\\php.exe",
  "phpunit.phpunit": "C:/xampp/htdocs/talentsuite/htdocs/vendor/phpunit/phpunit/phpunit",
  "phpunit.args": [
 "--configuration", "C:\\xampp\\htdocs\\talentsuite\\htdocs\\phpunit.xml",
@mknparreira
mknparreira / visual-studio-code-settings-json.md
Last active August 12, 2021 22:24
Visual Studio Code | settings.json
{
    "workbench.colorTheme": "Monokai",
    "files.autoSave": "onFocusChange",
    "editor.multiCursorModifier": "ctrlCmd",
    "editor.autoClosingBrackets": "always",
    "editor.autoClosingQuotes": "always",
    "editor.mouseWheelZoom": true,
    "workbench.editor.highlightModifiedTabs": true,
 "workbench.editor.enablePreview": false,
@mknparreira
mknparreira / laravel-group-query-result-by-day-month-year.md
Last active August 12, 2021 22:24
Laravel | Group query result by day month year

Introduction

Quick tip for those who want to list some events, grouping them by some date value – by day, month, year etc.

Let’s take a look at example – we have this database structure of appointments.

$days = Appointment::whereBetween('start_time', [now(), now()->addDays(7)])
    ->orderBy('start_time')
    ->get()
 ->groupBy(function ($val) {