Skip to content

Instantly share code, notes, and snippets.

View VictorHugoBatista's full-sized avatar
🛰️
Floating in the cyberspace

Victor Hugo Batista VictorHugoBatista

🛰️
Floating in the cyberspace
  • banQi
  • Internet
View GitHub Profile
@VictorHugoBatista
VictorHugoBatista / Demo_Mascara_Telefone.html
Last active June 17, 2017 19:59
Demo de máscara com expressão regular de telefone brasileiro que aceita número de 8 e 9 dígitos com DDD nos formatos (11) 2222-3333 e (11) 92222-3333. Fonte: http://elcio.com.br/ajax/mascara/
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Demo Máscara Telefone</title>
</head>
<body>
Telefone: <input onkeypress="mascaraTelefone(this)"/><br />
<script>
/*
@VictorHugoBatista
VictorHugoBatista / DotEnvHandler.php
Created May 31, 2017 01:39
Framework simples para manipulação de variáveis de ambiente via arquivos '.ENV'. Depende do pacote vlucas/phpdotenv (https://github.com/vlucas/phpdotenv)
<?php
namespace <VENDOR>\Environment;
use Dotenv\Dotenv;
/**
* Responsável pela manipulação de variáveis de ambiente.
* Tem o pacote 'vlucas/phpdotenv' como dependência.
* @see https://github.com/vlucas/phpdotenv
@VictorHugoBatista
VictorHugoBatista / get_cookies.js
Created June 2, 2017 21:04
Retorna um array relacional com todos os cookies via javascript sem o uso de frameworks ou bibliotecas.
function get_cookies() {
var cookies_raw = document.cookie.split(';'),
cookies = [];
$.each(cookies_raw, function(key, cookie){
cookie_array = cookie.split('=');
cookies[cookie_array[0]] = cookie_array[1];
});
return cookies;
}
@VictorHugoBatista
VictorHugoBatista / .sublime-settings
Created June 5, 2017 01:46
Sublime settings file, with material theme and Envy Code R font.
{
"always_show_minimap_viewport": true,
"bold_folder_labels": true,
"color_scheme": "Packages/Material Theme/schemes/Material-Theme.tmTheme",
"font_face": "Envy Code R",
"font_options":
[
"gray_antialias",
"subpixel_antialias"
],
@VictorHugoBatista
VictorHugoBatista / fix-wordpress-permissions.sh
Created September 7, 2018 13:41 — forked from Adirael/fix-wordpress-permissions.sh
Fix wordpress file permissions
#!/bin/bash
#
# This script configures WordPress file permissions based on recommendations
# from http://codex.wordpress.org/Hardening_WordPress#File_permissions
#
# Author: Michael Conigliaro <mike [at] conigliaro [dot] org>
#
WP_OWNER=www-data # <-- wordpress owner
WP_GROUP=www-data # <-- wordpress group
WP_ROOT=$1 # <-- wordpress root directory
@VictorHugoBatista
VictorHugoBatista / sql_import.php
Created October 8, 2018 01:08 — forked from ricardobrg/sql_import.php
WPDB SQL File import
<?php
/* NOTICE
* This script imports SQL commands "as is".
* Double check the SQL commands before using it
* and BACKUP YOUR DATABASE.
* It needs some improvement to use wpdb->prepare.
*/
class WPSQLImporter{
/**
* Loads an SQL stream into the WordPress database one command at a time.
@VictorHugoBatista
VictorHugoBatista / tmux-cheatsheet.markdown
Created October 14, 2018 13:34 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
We can make this file beautiful and searchable if this error is corrected: Unclosed quoted field in line 2.
ID,Type,SKU,Name,Published,"Is featured?","Visibility in catalog","Short description",Description,"Date sale price starts","Date sale price ends","Tax status","Tax class","In stock?",Stock,"Backorders allowed?","Sold individually?","Weight (lbs)","Length (in)","Width (in)","Height (in)","Allow customer reviews?","Purchase note","Sale price","Regular price",Categories,Tags,"Shipping class",Images,"Download limit","Download expiry days",Parent,"Grouped products",Upsells,Cross-sells,"External URL","Button text",Position,"Attribute 1 name","Attribute 1 value(s)","Attribute 1 visible","Attribute 1 global","Attribute 2 name","Attribute 2 value(s)","Attribute 2 visible","Attribute 2 global","Meta: _wpcom_is_markdown","Download 1 name","Download 1 URL","Download 2 name","Download 2 URL"
44,variable,woo-vneck-tee,"V-Neck T-Shirt",1,1,visible,"This is a variable product.","Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget,
@VictorHugoBatista
VictorHugoBatista / woocommerce-custom-fields.php
Created October 23, 2018 12:13
Adiciona custom fields ao woocommerce sem ACF
<?php
// Caggera os campos nas opções de preço do woocommerce.
// https://rudrastyh.com/woocommerce/product-data-metabox.html
// https://stackoverflow.com/questions/43700927/display-and-save-a-custom-field-in-product-variations-options-edit-page
add_action('woocommerce_product_options_pricing', function() {
global $woocommerce, $post;
$price_monthly = get_post_meta( $post->ID, 'price-monthly', true );
woocommerce_wp_text_input([
'id' => 'price-monthly',
@VictorHugoBatista
VictorHugoBatista / reveal-input-hidden.js
Created November 6, 2018 18:55
Reveal all inputs hidden on the page with his contents. Paste this on console terminal. This requires jQuery
(function($) {
$('input[type="hidden"]').attr('type', 'text');
})(jQuery);