Skip to content

Instantly share code, notes, and snippets.

View pedrorvidal's full-sized avatar

Pedro Vidal pedrorvidal

  • Porto Alegre, Brazil.
View GitHub Profile
add_filter( 'wp_head', function(){
if (is_page(XX) && !is_user_logged_in()) {
add_filter('the_content', function(){
return __('Sorry! Onlu logged-in user are allowed to see the content');
}, 99);
}
});
@pedrorvidal
pedrorvidal / brazil-cities-states-en.json
Created September 6, 2019 13:37 — forked from djalmaaraujo/brazil-cities-states-en.json
Cidades e estados brasileiros JSON & Javascript Object exported / Brazilian States and Cities in JSON or JS/Javascript
{
"states": [
{
"uf": "AC",
"name": "Acre",
"cities": [
"Acrelândia",
"Assis Brasil",
"Brasiléia",
"Bujari",
@pedrorvidal
pedrorvidal / tmux-cheatsheet.markdown
Created August 14, 2019 16:42 — forked from MohamedAlaa/tmux-cheatsheet.markdown
tmux shortcuts & cheatsheet

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@pedrorvidal
pedrorvidal / .tmux.conf
Created August 14, 2019 16:23 — forked from subfuzion/.tmux.conf
My .tmux.conf for tmux 2.1 (with fixes for mouse breakage)
# Inspirations:
# http://mutelight.org/practical-tmux
# http://zanshin.net/2013/09/05/my-tmux-configuration/
# http://files.floriancrouzat.net/dotfiles/.tmux.conf
# http://stackoverflow.com/questions/9628435/tmux-status-bar-configuration
# https://github.com/Lokaltog/powerline
# https://github.com/remiprev/teamocil
# http://superuser.com/questions/74492/whats-the-best-prefix-escape-sequence-for-screen-or-tmux
# http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/
#
@pedrorvidal
pedrorvidal / functions.php
Created July 28, 2019 19:08
Estados e cidades brasileiras populados em uma taxonomia do wordpress.
<?php
// É aconselhável criar um backup do banco antes
// crie a taxonomia cidade na functions do tema
add_action('init', 'register_locations');
function register_locations() {
register_taxonomy( 'cidade',array (
0 => 'locais',
),
array( 'hierarchical' => true,
@pedrorvidal
pedrorvidal / cloudSettings
Last active January 12, 2022 14:26
Visual Studio Code Settings Sync Gist
{"lastUpload":"2022-01-12T14:26:48.418Z","extensionVersion":"v3.4.3"}
@pedrorvidal
pedrorvidal / spotify_keybindings
Created July 4, 2017 19:16 — forked from jbonney/spotify_keybindings
Spotify - Linux key bindings. From XFCE / Ubuntu keyboard shortcuts configuration, assign the control command to their key. http://shkspr.mobi/blog/2011/12/linux-spotify-keybindings/
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.PlayPause" XF86AudioPlay
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Stop" XF86AudioStop
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Next" XF86AudioNext
"dbus-send --print-reply --dest=org.mpris.MediaPlayer2.spotify /org/mpris/MediaPlayer2 org.mpris.MediaPlayer2.Player.Previous" XF86AudioPrevious
@pedrorvidal
pedrorvidal / custom-loop.php
Created May 16, 2017 14:25
WP Sort by multiple meta's
<?php
$WP_categorias_filtro = array(
'post_type' => array('proposta', 'problema'),
'posts_per_page' => 6,
'meta_query' => array(
'relation' => 'OR',
'contagem' => array(
'key' => 'contagem_views',
'type' => 'NUMERIC',
'compare' => 'EXISTS'
@pedrorvidal
pedrorvidal / functions.php
Created May 2, 2017 18:05
WordPress sanitize Filename
/**
* Arquivos acentuados no upload do WordPress
* @url https://wordpress.org/support/topic/uploaded-image-with-accents-in-name-image-dont-show-in-safari-6
*/
function sanitize_filename_on_upload($filename) {
$param = explode('.', $filename);
$ext = end($param);
// Replace all weird characters
$sanitized = preg_replace('/[^a-zA-Z0-9-_.]/', '', substr($filename, 0, -(strlen($ext)+1)));
// Replace dots inside filename
@pedrorvidal
pedrorvidal / fix-wordpress-permissions.sh
Last active March 3, 2017 01:15 — 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>
#
#
# RODAR USANDO ./fix-wordpress-permissions.sh <nome_da_pasta_wordpress>
#