Skip to content

Instantly share code, notes, and snippets.

View saade's full-sized avatar
🦒
Starting a new side-project using Filament ... probably

Guilherme Saade saade

🦒
Starting a new side-project using Filament ... probably
View GitHub Profile
@saade
saade / gist:20a054a22233c91f00843a12f0775160
Created September 13, 2018 20:19
Make mysql accept emoji
# For each database:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a `VARCHAR` column.)
@saade
saade / gist:85a811ea2f09899f475a0f80068a9f5e
Created September 13, 2018 20:19
Make mysql accept emoji
# For each database:
ALTER DATABASE database_name CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci;
# For each table:
ALTER TABLE table_name CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# For each column:
ALTER TABLE table_name CHANGE column_name column_name VARCHAR(191) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;
# (Don’t blindly copy-paste this! The exact statement depends on the column type, maximum length, and other properties. The above line is just an example for a `VARCHAR` column.)
@saade
saade / cluster.md
Created December 4, 2018 01:18 — forked from learncodeacademy/cluster.md
Node Cluster - Enhance your node app by using all the cores of your processor.

Here's all you have to do to add clustering to your node.js application.

  • save this code as cluster.js, and run cluster.js instead of server.js (or /bin/www, or whatever it's called for your project)
  • the only line you'll need to change is the last line - it needs to point to the location of your server.js file
var cluster = require('cluster');

if (cluster.isMaster) {
  // Count the machine's CPUs
 var cpuCount = require('os').cpus().length;
@saade
saade / en-validation.json
Created September 20, 2020 20:20 — forked from diego3g/en-validation.json
Validation
{
"above": "The {{field}} should be above {{argument.0}}.",
"accepted": "The {{field}} should have been accepted",
"after": "The {{field}} should be a date after {{argument.0}}",
"after_offset_of": "The {{field}} should be after {{argument.0}} {{argument.1}} from today’s date",
"alpha": "The {{field}} should contain letters only",
"alpha_numeric": "The {{field}} should contain letters and numbers only",
"array": "The {{field}} should be an ARRAY.",
"before": "The {{field}} should be a date before {{argument.0}}.",
"before_offset_of": "The {{field}} should be before {{argument.0}} {{argument.1}} from today’s date",
@saade
saade / gist:666493b9cc05ab28de5f7766e36157ed
Created July 14, 2021 15:02
Delete all workflow runs
user=GH_USERNAME repo=REPO_NAME; gh api repos/$user/$repo/actions/runs \
--paginate -q '.workflow_runs[] | select(.head_branch != "master") | "\(.id)"' | \
xargs -n1 -I % gh api repos/$user/$repo/actions/runs/% -X DELETE
@saade
saade / puntu-export.js
Last active January 3, 2022 13:42
Puntu CSV Export
const controller = new AbortController()
const timeoutId = setTimeout(() => controller.abort(), 1000 * 60)
const date = new Date();
const m = parseInt(prompt('Digite o mês que deseja exportar', date.getMonth() + 1)) - 1;
const y = prompt('Digite o ano que deseja exportar', date.getFullYear());
if( window.location.host !== 'app.puntu.com.br' ) {
prompt('Para usar o script, vá para o Puntu Web.', 'https://app.puntu.com.br');
@saade
saade / If above does not work.txt
Created February 6, 2022 21:42
Fix WSL ethernet connection.
=============================================================================
FIX WSL2 NETWORKING IN WINDOWS 10
=============================================================================
cmd as admin:
wsl --shutdown
netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns
@saade
saade / .bashrc
Created March 18, 2022 17:54
Switch php versions in Laravel Valet
phpv() {
valet stop
brew unlink php@7.4 php@8.1
brew link --force --overwrite $1
brew services start $1
composer global update
rm -f ~/.config/valet/valet.sock
valet install
}
@saade
saade / ShadeGenerator.php
Created October 28, 2022 20:39
Tailwindcss Shade Generator PHP
<?php
namespace App\Support;
use Exception;
use Spatie\Color\Hex;
use Spatie\Color\Rgb;
class ShadeGenerator
{
@saade
saade / Gov.js
Last active July 4, 2024 14:52
Webview scripts
const observer = new MutationObserver(async () => {
if (window.location.pathname !== '/form') return;
const user = await window.flutter_inappwebview.callHandler("user");
if (!user) {
alert("Você não está logado.");
}
function getReactProps (el) {