Skip to content

Instantly share code, notes, and snippets.

View mariovalney's full-sized avatar
🏠
Working from home

Mário Valney mariovalney

🏠
Working from home
View GitHub Profile
@mariovalney
mariovalney / wc-products-shortcode-by-user.php
Last active January 20, 2020 18:56
WC Products Shortcode by User
<?php
/**
*
* Plugin Name: WC Products Shortcode by User
* Description: Ass "current_user" to [products] shortcode to show only products from current user.
* Version: 1.0.0
* Author: Mário Valney
* Author URI: https://mariovalney.com
* Text Domain: wc-products-shortcode-by-user
*
@mariovalney
mariovalney / script.php
Created December 4, 2019 17:29
Turn exported WooCommerce/WordPress Orders into CSV file
<?php
header("Content-type: text/csv");
header("Content-Disposition: attachment; filename=file.csv");
header("Pragma: no-cache");
header("Expires: 0");
// Load file
$xml_string = file_get_contents(dirname(__FILE__) . '/file.xml');
str_replace($xml_string, 'dc:', 'dc-');
@mariovalney
mariovalney / SavePNG4XP.jsx
Last active November 13, 2019 19:20
This script is designed to be used as a script that runs after a save event. It's based on default 'Save Extra JPEG' and will save a PNG next to the current active if 'X-Plane' or 'Aircraft' are presented on path. This script does not handle 'as a copy' when saving.
/**
* Developed by Mário Valney <mariovalney@gmail.com>
*
* Inspired on "Save Extra JPEG" and created using:
* https://www.adobe.com/content/dam/acom/en/devnet/photoshop/pdfs/photoshop_scriptref_js.pdf
*/
/**
* @@@BUILDINFO@@@ Save PNG 4 XP.jsx 1.0.0 Thu Oct 24 2019 19:21:44 GMT-0300
*/
@mariovalney
mariovalney / monitor.js
Created August 6, 2019 13:39
Monitor a API Endpoint to check JSON and sent data to Slack
"use strict";
const API_URL = "https://api.example.com/your-endpoint"; // Your API request
const SLACK_URL = ""; // Check: https://api.slack.com/incoming-webhooks
const NOTIFICATION = {text: "ITEM I WANT CHANGED!"}; // Message sent to Slack
const INTERVAL = 60000; // Interval in miliseconds
const interval = setInterval(() => {
fetch(API_URL)
.then(response => {
@mariovalney
mariovalney / vizir-masks.js
Created June 26, 2019 16:00
Add the most used masks. Requires jQuery Mask Plugin.
'use strict';
jQuery(document).ready(function($) {
// Nineth Digit behavior
var ninethDigitMask = function( val ) {
return ( val.replace( /\D/g, '' ).length === 11 ) ? '(00) 00000-0000' : '(00) 0000-00009';
}
// Multiple Documents Behaviour
var multipleDocumentsMask = function( val, e, field, options ) {
@mariovalney
mariovalney / Database.php
Last active June 6, 2019 00:42
A simple implementation of Active Record.
<?php
namespace App\Database;
interface Database
{
public static function getInstance();
public function create(string $table, array $columns);
@mariovalney
mariovalney / unique-string-id.php
Last active May 16, 2019 15:41
Return a string replacing a placeholder by a sequential number.
<?php
/**
* Return a string replacing placeholder by a number
*
* You can create 'item-1', 'item-2', 'item-3'... globally
* just calling unique_string_id('item{id}')
*
* @param string $string
* @param bool $includeOne
@mariovalney
mariovalney / console.js
Created April 10, 2019 18:20
Marcar todas respostas como "Ótimo" nas Avaliações de Docente da Unifametro.
// 1 - Ótimo / 5 - Péssimo
var checkboxes = $$('[value="1"]');
for (var i = 0; i < checkboxes.length; i++) {
checkboxes[i].checked = true;
}
@mariovalney
mariovalney / wp-thanos.php
Created April 5, 2019 20:20
Snap half of all users from your site.
<?php
/**
* Plugin Name: WP Thanos
* Description: Snap half of all users from your site.
* Version: 1.0.0
* Plugin URI: https://gist.github.com/mariovalney/936e70dbc1ea84396afe4683b531c642
* Author: Mário Valney
* Author URI: https://valney.dev
* Text Domain: wp-thanos
*/
@mariovalney
mariovalney / pre-commit
Last active April 21, 2024 06:47
Pre-commit hook to check code with PHPCS, fix with PHPCBF and check mess with PHPMD
#!/bin/sh
#########################
# #
# Initializing #
# #
#########################
##
# You should add all tools as composer dependencies or change this path