Skip to content

Instantly share code, notes, and snippets.

💭
never stop.

Matheus Pratta MatheusMK3

💭
never stop.
Block or report user

Report or block MatheusMK3

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@MatheusMK3
MatheusMK3 / fix.wp-mysql8-onlyfullgroupby.php
Last active Oct 24, 2019
🔧 Fixes errors regarding ONLY_FULL_GROUP_BY when using WordPress with managed database services using MySQL 8.
View fix.wp-mysql8-onlyfullgroupby.php
<?php
/*
Plugin Name: WP Managed MySQL 8 Fix
Plugin URI: https://gist.github.com/MatheusMK3/4f3acb29ac4fb0e9a03318bcacec1972
Description: Fixes issues regarding MySQL modes (ONLY_FULL_GROUP_BY) when on managed database services.
Author: Matheus Pratta
Version: 1.0.0
Author URI: https://matheus.io
*/
@MatheusMK3
MatheusMK3 / fn.useragent-router.js
Created Sep 21, 2019
Very basic user-agent based router for Now.sh, to be coupled with @now/static-build builds.
View fn.useragent-router.js
const https = require('https')
let cachedIndex = null
let cachedIndexHeaders = null
// Function to handle our OpenGraph tags
const handleOpenGraphUA = ['Twitterbot', 'Facebot', 'facebookexternalhit']
const handleOpenGraph = (req, res) => {
// Check if we're serving Twitter or Facebook bots
const requestUA = req.headers['user-agent']
View keybase.md

Keybase proof

I hereby claim:

  • I am matheusmk3 on github.
  • I am matt_pratta (https://keybase.io/matt_pratta) on keybase.
  • I have a public key ASDtG3s8ze8nRwrdpdrAOs2cwtplnNiwkhHoXNAEzSTCvAo

To claim this, I am signing this object:

@MatheusMK3
MatheusMK3 / fn.debounce.js
Last active Jul 31, 2019
Função para debounce de eventos em Javascript
View fn.debounce.js
function debounce (fn, time) {
// Estado do throttle
let throttling = false
// Retorna uma função especial para fazer o debounce
return () => {
// Se estiver com throttle ativo, retornar
if (throttling) return;
// Ativa o throttle
@MatheusMK3
MatheusMK3 / fn.textToCharBlocks.js
Created May 24, 2019
Converts a string of text into an array of text blocks
View fn.textToCharBlocks.js
/**
* Converts a string of text into an array of text blocks with a maximum size of blockSize.
* @author Matheus Pratta <eu@matheus.io>
* @param {string} text
* @param {int} blockSize
* @returns {array}
*/
function textToCharBlocks (text, blockSize) {
let textBlocks = []; // Array containing our text blocks
let currentBlock = ''; // accumulator
@MatheusMK3
MatheusMK3 / OneDarkProX.itermcolors
Created Apr 17, 2019
My settings for CMD.exe colors, use with colortool
View OneDarkProX.itermcolors
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Ansi 0 Color</key>
<dict>
<key>Color Space</key>
<string>sRGB</string>
<key>Blue Component</key>
<real>0.20392156862745098</real>
@MatheusMK3
MatheusMK3 / fn.debug_object.js
Last active May 24, 2019
Returns a complete human-readable breakdown of a Javascript object
View fn.debug_object.js
/**
* debug_object (1.0.0)
* Returns a complete human-readable breakdown of a Javascript object
* Author: Matheus Pratta <https://github.com/matheusmk3>
*/
function debug_object (obj, braces, level) {
// Recursion level
if (!level) level = braces ? 1 : 0;
// Identation
View wpu_get_nav_menu.fn.php
<?php
/**
* Processa um menu do WordPress de acordo com a localização no tema
* Sintaxe: wpu_get_nav_menu ($localização, $returns = null)
* Sintaxe: wpu_get_nav_menu_array ($menu, $args = array())
* Autor: Matheus Pratta <eu@matheus.io>
*/
function wpu_get_nav_menu ($location, $returns = null) {
// Obtemos as posições de menu no tema
View fn.find_best_match.php
<?php
/**
* string find_best_match (string $word, array $db, float &$best_match_score);
* Compares $word with each ocurrence in $db, then results the closest matching string.
* Also returns how much both words matched in %.
*/
function find_best_match ($word, $db, &$best_match_score) {
// Initialize our comparison variables
$best_match = $word;
$best_match_score = 0;
@MatheusMK3
MatheusMK3 / popups-infinitos.html
Created Apr 22, 2018
Exemplo de bug no Chrome, que permite criação de popups infinitos sem interação de usuário.
View popups-infinitos.html
<!DOCTYPE html>
<html>
<head>
<title>Google Chrome Popup Bypass</title>
<script type="text/javascript">
/**
* Fonte: Custom Chromium Build to Reverse Engineer Pop-Under Trick <https://www.youtube.com/watch?v=y6Uzinz3DRU>
* Por algum motivo, os eventos "message" do Chrome são tratados como ações causadas pelo usuário, o que resulta na possibilidade de se criar popups infinitos, sem qualquer interação do usuário.
* Também possibilita exibir mais de um popup a partir de cliques de mouse e até mesmo a criação de "popunder", um popup que fica abaixo da janela atual.
*/
You can’t perform that action at this time.