Skip to content

Instantly share code, notes, and snippets.

@locopine
locopine / git-force-clone.sh
Created March 23, 2022 22:27 — forked from nottrobin/git-force-clone.sh
git force-clone: clone a repository; if it already exists locally, reset it to a clone of the remote.
#! /usr/bin/env bash
set -euo pipefail
_usage() {
echo "
Usage:
git-force-clone -b branch remote_url destination_path
Example:

Conventinal Commit Messages

See how a minor change to your commit message style can make a difference. Examples

Have a look at CLI util git-conventional-commits to ensure this conventions and generate changelogs

Commit Formats

Default

@locopine
locopine / max_key_length_is_767_bytes.md
Created April 1, 2022 16:12
Laravel + MySQL <= 5.6.x - Syntax error or access violation: 1071 Specified key was too long;

Por quê MySQL retorna exceção ao executar migração em ambiende MySQL <= v5.6.x.

Illuminate\Database\QueryException 

  SQLSTATE[42000]: Syntax error or access violation: 1071 Specified key was too long; max key length is 767 bytes (SQL: alter table `users` add unique `users_email_unique`(`email`))

Após longo debate com o suporte de uma famosa empresa de hospedagem e colocado em uma fila de espera para ter o DB migrado para versão MySQL >= v. 5.7, fiz minha própria analise para entender o porquê de tal comportamento. Consultei informações na web e me deparei com alguns comentários referente a cálculo de bytes, como pode ser visto no site Stack Exchange mais especificamente na parte de Database Administrators, onde no final de uma das respostas uma observação feita chamou minha atenção: "Also, have a look at why varchar(255) is a bad idea."!

@locopine
locopine / .env-Swoole
Created April 26, 2022 02:15 — forked from kiddtang/.env-Swoole
Youtube - Boosts your Laravel Sail
OCTANE_SERVER=swoole
OCTANE_HTTPS=true
@locopine
locopine / slash-search.js
Created June 28, 2022 22:16 — forked from caspark/slash-search.js
Google slash search
// ==UserScript==
// @name Google Slash Search
// @namespace http://tampermonkey.net/
// @version 0.1
// @description try to take over the world!
// @author You
// @match https://www.google.com/search*
// @grant none
// ==/UserScript==
@locopine
locopine / macro.md
Created July 12, 2022 09:39 — forked from brunogaspar/macro.md
Recursive Laravel Collection Macros

What?

If a nested array is passed into a Laravel Collection, by default these will be threaded as normal arrays.

However, that's not always the ideal case and it would be nice if we could have nested collections in a cleaner way.

This is where this macro comes in handy.

Setup

# Para um novo projeto, crie esta estrutura
[dev-user1] $ mkdir projeto
[dev-user1] $ cd projeto
[dev-user1] $ git init
[dev-user1] $ touch README
[dev-user1] $ git add .
[dev-user1] $ git commit -am "Initial commit"
# Crie no servidor um repositório do tipo bare para "guardar" os commits
[bare-server1] $ mkdir -p /git/projeto
@locopine
locopine / DashboardController.php
Created September 17, 2022 12:21 — forked from Loupeznik/DashboardController.php
Laravel Visitor Counter - data visualization
// app/Http/Controllers/DashboardController.php
<?php
namespace App\Http\Controllers;
use App\Models\Visitor;
use Illuminate\Support\Facades\DB;
class DashboardController extends Controller
{
@locopine
locopine / recommended-settings.json
Created November 9, 2022 19:47 — forked from DoctorDerek/recommended-settings.json
Recommended settings.json file for new web developers setting up VS Code according to https://medium.com/p/65aaa5788c0d/ by Dr. Derek Austin 🥳
@locopine
locopine / drop-table
Created January 12, 2023 23:50 — forked from sohelamin/drop-table
Laravel drop tables via artisan command
php artisan tinker
$tables = DB::select('SHOW TABLES');
$tables_in_database = "Tables_in_".Config::get('database.connections.mysql.database');
DB::statement('SET FOREIGN_KEY_CHECKS=0;');
foreach ($tables as $table) {
Schema::drop($table->$tables_in_database);
}