Skip to content

Instantly share code, notes, and snippets.

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

Tiago Bega tsbega

🏠
Working from home
View GitHub Profile
@tsbega
tsbega / functions.php
Created July 20, 2017 21:35 — forked from ofernandolopes/functions.php
Limit Authors to their Own Posts in WordPress Admin
function posts_for_current_author($query) {
global $pagenow;
if( 'edit.php' != $pagenow || !$query->is_admin )
return $query;
if( !current_user_can( 'manage_options' ) ) {
global $user_ID;
$query->set('author', $user_ID );
}
return $query;
}
@tsbega
tsbega / Main.java
Created June 19, 2018 19:03 — forked from JFRode/Main.java
SQL para registro de todos os estados e cidades do Brasil
package jfrode.jsontosql.main;
import java.io.BufferedReader;
import java.io.FileReader;
import org.json.JSONArray;
import org.json.JSONObject;
/**
*
@tsbega
tsbega / Main.java
Created June 19, 2018 19:03 — forked from JFRode/Main.java
SQL para registro de todos os estados e cidades do Brasil
package jfrode.jsontosql.main;
import java.io.BufferedReader;
import java.io.FileReader;
import org.json.JSONArray;
import org.json.JSONObject;
/**
*
@tsbega
tsbega / estados-cidades.json
Created June 19, 2018 19:04 — forked from letanure/estados-cidades.json
JSON estados cidades
{
"estados": [
{
"sigla": "AC",
"nome": "Acre",
"cidades": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@tsbega
tsbega / magento-nginx.conf
Created August 23, 2018 14:47 — forked from gwillem/magento-nginx.conf
Battle-tested Nginx configuration for Magento (source: www.hypernode.com)
# This is an annotated subset of the Nginx configuration from our Magento production platform @ www.hypernode.com
# See https://www.byte.nl/blog/magento-cacheleak-issue
# !!!! If you are a Hypernode customer, do not use this config as it will result in duplicate statements. !!!!!
user app;
worker_processes 4;
pid /var/run/nginx.pid;
events {
@tsbega
tsbega / woocommerce-optimize-scripts.php
Created January 19, 2019 13:03 — forked from DevinWalker/woocommerce-optimize-scripts.php
Only load WooCommerce scripts on shop pages and checkout + cart
/**
* Optimize WooCommerce Scripts
* Remove WooCommerce Generator tag, styles, and scripts from non WooCommerce pages.
*/
add_action( 'wp_enqueue_scripts', 'child_manage_woocommerce_styles', 99 );
function child_manage_woocommerce_styles() {
//remove generator meta tag
remove_action( 'wp_head', array( $GLOBALS['woocommerce'], 'generator' ) );
@tsbega
tsbega / custom-login-styles.css
Created January 30, 2019 13:16 — forked from gugaalves/custom-login-styles.css
WordPress - Customizing Login, Register and Lost Password pages
/*
*
* This CSS template will customize WordPress.org login page:
*
* Login page: /wp-login.php
* Register page: /wp-login.php?action=register
* Lost Password page: /wp-login.php?action=lostpassword
*
* @site https://tudoparawp.com.br
* @author Guga Alves
@tsbega
tsbega / optimize-images.sh
Last active October 7, 2020 01:29 — forked from rkbhochalya/optimize-images.sh
Recursively optimize PNG and JPEG images using convert command
# Recursively optimize PNG and JPEG images using convert command
#
# `convert` is part of ImageMagick (http://www.imagemagick.org/). You will need to install it first.
#
# Author: Rajendra Kumar Bhochalya (http://rkb.io)
#
# @see https://developers.google.com/speed/docs/insights/OptimizeImages
# Optimize all JPEG images in current directory and subdirectories
find . -name "*.jpg" -exec convert "{}" -sampling-factor 4:2:0 -strip -quality 85 -interlace JPEG -colorspace RGB "{}" \; -exec echo "{}" \;
<?php
function show_template() {
global $template;
print_r($template);
}
add_action('wp_footer', 'show_template');
?>
@tsbega
tsbega / .htaccess
Last active February 20, 2020 17:24 — forked from boogah/.htaccess
Expire headers .htaccess code.
<IfModule mod_expires.c>
ExpiresActive on
# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault "access plus 1 month"
# Data
ExpiresByType text/xml "access plus 0 seconds"
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType application/json "access plus 0 seconds"