Skip to content

Instantly share code, notes, and snippets.

View luizventurote's full-sized avatar

Luiz Venturote luizventurote

View GitHub Profile
@luizventurote
luizventurote / required-featured-image.php
Last active August 29, 2015 13:57
Alerta de uso obrigatório de imagem destacada antes da publicação de qualquer artigo.
@luizventurote
luizventurote / age-function.sql
Last active August 29, 2015 13:57
SQL function that returns the age.
DROP FUNCTION IF EXISTS fn_idade;
DELIMITER $$
CREATE FUNCTION fn_idade(data_nascimento DATE)
RETURNS INT
LANGUAGE SQL
BEGIN
RETURN (Year(Curdate()) - Year(data_nascimento)) -(Right(Curdate(),5) < (Right(data_nascimento,5)));
END;
@luizventurote
luizventurote / ahp-algorithm.c
Created March 31, 2014 21:02
Analytic hierarchy process algorithm.
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define TAM 100
#define QUA 100
struct Alternativas
{
float nota[TAM];
float classificacao[TAM][TAM];
@luizventurote
luizventurote / wordpress-snippets.php
Last active August 29, 2015 13:58
Wordpress Snippets.
<!-- Get Head -->
<?php wp_head(); ?>
<!-- The title -->
<?php wp_title(''); ?>
<!-- Get Template Directory URI -->
<?php echo get_template_directory_uri(); ?>
@luizventurote
luizventurote / wp-dropdown-menu-of-categories.php
Last active September 25, 2021 21:59
Dropdown menu of categories with Walker.
<?php
# Walker Class
class my_Walker_CategoryDropdown extends Walker_CategoryDropdown {
function start_el(&$output, $category, $depth, $args) {
$pad = str_repeat('&nbsp;', $depth * 3);
$cat_name = apply_filters('list_cats', $category->name, $category);
@luizventurote
luizventurote / wordpress-post-snippets.php
Last active August 29, 2015 13:58
Snippets for Wordpress posts.
<?php
/**
* get_the_date - Retrieves the date the current $post was written
*/
get_the_date( $date );
/**
* get_comments_number - Retrieves the value of the total number of comments for a post.
*/
<?php
// Nav Menu Dropdown Class
include_once( CHILD_DIR . '/lib/classes/nav-menu-dropdown.php' );
/**
* Mobile Menu
*
*/
function be_mobile_menu() {
@luizventurote
luizventurote / truncate-string-words.php
Last active April 8, 2016 08:49
Truncate a string provided by the maximum limit without breaking a word.
<?php
/**
* truncate a string provided by the maximum limit without breaking a word
* @param string $str
* @param integer $maxlen
* @return string
*/
function truncateStringWords($str, $maxlen) {
if (strlen($str) <= $maxlen) return $str;
@luizventurote
luizventurote / Aluno.java
Created April 10, 2014 12:24
Exercício de diagrama de classes - Aula de UML para código.
package escola;
import java.util.ArrayList;
public class Aluno extends Pessoa {
private int numeroMatricula;
private int anoInicioCurso;
private Bolsa bolsa;
private ArrayList<Disciplina> disciplinas;
@luizventurote
luizventurote / google-maps-converting.php
Created April 13, 2014 02:50
Converting address to latitude and longitude - Google Maps - PHP.
<?php
/**
* Converting address to latitude and longitude
*/
function setLatitudeAndLongitude($address) {
$address = urlencode($address);
$request_url = "http://maps.googleapis.com/maps/api/geocode/xml?address=".$address."&sensor=true";
$xml = simplexml_load_file($request_url) or die("url not loading");
$status = $xml->status;