Skip to content

Instantly share code, notes, and snippets.

DROP FUNCTION IF EXISTS `slug`;
DELIMITER //
CREATE FUNCTION `slug`(`str` TEXT)
RETURNS text
LANGUAGE SQL
DETERMINISTIC
NO SQL
SQL SECURITY INVOKER
COMMENT ''
@douglascabral
douglascabral / proxy-apache-example.conf
Last active January 29, 2018 15:45
Example of Apache Proxy
<VirtualHost *:80>
ServerName nome-do-servidor.com.br
ServerAdmin webmaster@localhost
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
ProxyPass / http://127.0.0.1:8082/
ProxyPassReverse / http://127.0.0.1:8082/
SELECT
@rownum := @rownum + 1 AS rownumber
FROM
(SELECT @rownum := 0) AS tbl_rownumber
@douglascabral
douglascabral / jwt.php
Last active July 25, 2023 03:44
Example of JWT with Pure PHP
<?php
$key = 'your-secret-key-here';
$header = [
'typ' => 'JWT',
'alg' => 'HS256'
];
$header = json_encode($header);
$header = base64_encode($header);
for branch in `git branch -r | cut -d '/' -f2` ; do git checkout $branch && git pull origin $branch ; done
@douglascabral
douglascabral / mysql-dump-data.sql
Created June 16, 2016 15:01
MySQL Dump data (No Downtime)
mysqldump <DATABASE> --host=<HOST_IP> \
--user=<USER> \
--password=<PASSWORD> \
--port=3306 \
--single-transaction \
--compress \
--skip-comments \
--skip-add-locks \
--skip-triggers \
--no-create-db \
@douglascabral
douglascabral / mysql-dump-struct.sql
Last active June 16, 2016 14:25
MySQL Dump with triggers, views and no-lock (No Downtime)
mysqldump <DATABASE> --host=<IP_HOST> \
--user=<USER> \
--password=<PASSWORD> \
--port=3306 \
--single-transaction \
--routines \
--triggers \
--compress \
--no-set-names \
--skip-add-locks \
@douglascabral
douglascabral / functions.php
Created May 30, 2016 18:43
Remove menus admin WP
//
// Remove menus do admin
//
function remove_menus(){
remove_menu_page( 'index.php' ); //Dashboard
//remove_menu_page( 'edit.php' ); //Posts
remove_menu_page( 'upload.php' ); //Media
//remove_menu_page( 'edit.php?post_type=page' ); //Pages
remove_menu_page( 'edit-comments.php' ); //Comments
remove_menu_page( 'link-manager.php' ); //Links
@douglascabral
douglascabral / functions.php
Created May 30, 2016 18:42
Remove updates WP
//
// Remove aviso de atualização
// Obs: Aparenta deixar o admin um pouco mais lento para mudar de página
//
remove_action( 'load-update-core.php', 'wp_update_plugins' );
add_filter( 'pre_site_transient_update_core', create_function('$a', "return null;") );
add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) );
@douglascabral
douglascabral / render_css_scripts.php
Created May 30, 2016 12:44
Enqueue Styles e Scripts versioned in WP.
//
// Enqueue Styles e Scripts.
//
function render_css( $name, $path ) {
if ( preg_match('/^(\/\/|http)/', $path ) ) {
wp_enqueue_style( $name, $path );
} else if ( file_exists( get_template_directory() . $path ) ) {
$hash = md5_file( get_template_directory() . $path );
$path = get_template_directory_uri() . $path;
wp_enqueue_style( $name, $path, array(), $hash );