Skip to content

Instantly share code, notes, and snippets.

View matpratta's full-sized avatar

Matheus Pratta matpratta

View GitHub Profile
@matpratta
matpratta / du-seamless-animated-images.rs.lua
Last active August 8, 2023 16:53
🖥️ DU Render Script: Seamless Animated Images
-- Demo settings, fill them in with the data from your sprite sheet:
-- - Image: the uploaded link to the image
-- - Cols: number of columns on your sheet
-- - Rows: number of rows on your sheet
-- - FPS: desired frame rate for the animation
-- - Skip: how many frames are missing at end of sheet, used for seamless loops
local image = 'assets.prod.novaquark.com/113304/503a53c7-3fc0-418e-bb59-97e2dfcf1b8d.jpg'
local cols = 19
local rows = 12
@matpratta
matpratta / du-global-dump.lua
Created September 1, 2022 16:03 — forked from d-lua-stuff/dump.lua
Global variable dumping script for Dual Universe. See https://board.dualthegame.com/index.php?/topic/20052-lua-all-global-variables/ for more info. License: WTFPL
local max = math.max
local concat, insert = table.concat, table.insert
local byte, gsub, format, match, rep = string.byte, string.gsub, string.format, string.match, string.rep
local buffer = { "Lua globals dump: \r\n\r\n" }
local should_get_function_params = true
local should_dump_functions = false
local table_visited = {}
@matpratta
matpratta / espruino-serial-mixed-mode.js
Created June 4, 2022 03:34
Small Espruino thingy that allows for bidirectional serial communication while also detecting Espruino IDE for development
// Start init
console.log('Preparing JS environment...');
console.log('Booting I2c...');
I2C1.setup({scl:NodeMCU.D1, sda:NodeMCU.D2});
// Command object
var COMMANDS = {};
// Response
@matpratta
matpratta / se-analog-basic-control.cs
Created February 20, 2022 22:54
🚀 Compiled SE AnalogThrottle sample script
/*
* 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" };
@matpratta
matpratta / slimplicity.omp.json
Created September 6, 2021 20:13
🎨 Slimplicity, a modded "slim" theme for PowerShell & oh-my-posh
{
"$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",
@matpratta
matpratta / fn.flatten_redirect_chain.php
Created August 17, 2020 17:48
🔗 Follows a redirect chain path and either redirects to the final URL or returns it
/**
* 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
*
@matpratta
matpratta / cron-fix-wordpress-upload-permissions.sh
Last active April 1, 2020 21:15
🔧 Fixes WordPress upload directories permissions being set to root, use it with crontab.
#!/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`
@matpratta
matpratta / fix.wp-mysql8-onlyfullgroupby.php
Last active October 24, 2019 18:59
🔧 Fixes errors regarding ONLY_FULL_GROUP_BY when using WordPress with managed database services using MySQL 8.
<?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
*/
@matpratta
matpratta / fn.useragent-router.js
Created September 21, 2019 00:13
Very basic user-agent based router for Now.sh, to be coupled with @now/static-build builds.
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']