Skip to content

Instantly share code, notes, and snippets.

@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
{
# 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 / 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

@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 / .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 / 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."!

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 / 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:
@locopine
locopine / .jsbeautifyrc
Last active March 19, 2022 23:56
Beautifier for javascript e etc...
{
"__comment1":"js-beaultify - https://github.com/beautify-web/js-beautify",
"__comment2":"blade",
"blade.php": {
"brace_style": "collapse",
"indent_char": " ",
"indent_scripts": "normal",
"indent_size": 6,
"max_preserve_newlines": 1,
"other": " ",
@locopine
locopine / xrandr.sh
Created February 25, 2022 20:18 — forked from debloper/xrandr.sh
Add system unrecognized but monitor supported resolution in X
#!/bin/bash
# Copyright (c) 2021 Soumya Deb <[email protected]>
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions: