Skip to content

Instantly share code, notes, and snippets.

Avatar
🦄
building tomorrow's web.

Matheus Pratta MatheusMK3

🦄
building tomorrow's web.
View GitHub Profile
@MatheusMK3
MatheusMK3 / espruino-serial-mixed-mode.js
Created Jun 4, 2022
Small Espruino thingy that allows for bidirectional serial communication while also detecting Espruino IDE for development
View espruino-serial-mixed-mode.js
// Start init
console.log('Preparing JS environment...');
console.log('Booting I2c...');
I2C1.setup({scl:NodeMCU.D1, sda:NodeMCU.D2});
// Command object
var COMMANDS = {};
// Response
@MatheusMK3
MatheusMK3 / se-analog-basic-control.cs
Created Feb 20, 2022
🚀 Compiled SE AnalogThrottle sample script
View se-analog-basic-control.cs
/*
* R e a d m e
* -----------
*
* In this file you can include any instructions or other comments you want to have injected onto the
* top of your final script. You can safely delete this file if you do not want any such comments.
*/
// List of valid axis types
private readonly string[] AXIS_TYPES = new string[] { "Normal", "Center", "Reverse" };
@MatheusMK3
MatheusMK3 / slimplicity.omp.json
Created Sep 6, 2021
🎨 Slimplicity, a modded "slim" theme for PowerShell & oh-my-posh
View slimplicity.omp.json
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"final_space": true,
"console_title": true,
"console_title_style": "template",
"console_title_template": "{{if .Root}}root :: {{end}}{{.Shell}} :: {{.Folder}}",
"blocks": [
{
"type": "prompt",
"alignment": "left",
@MatheusMK3
MatheusMK3 / fn.flatten_redirect_chain.php
Created Aug 17, 2020
🔗 Follows a redirect chain path and either redirects to the final URL or returns it
View fn.flatten_redirect_chain.php
/**
* fn.flatten_redirect_chain.php
* Follows a redirect chain path and either redirects to the final URL or returns it
* Author: Matheus Pratta <github.com/matheusmk3>
* License: 0BSD
* Version: 1.0.0
*
* @param string $destination The URL that is part of a redirect chain and shall be resolved
* @param mixed $redirect The redirect type to be used (301/302) or false for returning the final URL as string
*
@MatheusMK3
MatheusMK3 / cron-fix-wordpress-upload-permissions.sh
Last active Apr 1, 2020
🔧 Fixes WordPress upload directories permissions being set to root, use it with crontab.
View cron-fix-wordpress-upload-permissions.sh
#!/bin/bash
# Set this to your server's owner user (normally www-data)
user="www-data:www-data"
# Set this to the path to your wp-content
wp_content_path="/var/www/html/wp-content"
# Gets current year and month numbers
year=`date +%Y`
View connect-displaylink.sh
@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