Skip to content

Instantly share code, notes, and snippets.

View brendomaciel's full-sized avatar

Brendo Maciel brendomaciel

  • Else Consultoria
  • Brazil
View GitHub Profile
@brendomaciel
brendomaciel / javascript_stranger_things.md
Last active November 6, 2016 01:06
JavaScript "Stranger Things"

JavaScript "Stranger Things"

O JavaScript possui uma série de curiosidades em relação a algumas instruções. Portanto, tome cuidado se precisar utilizar qualquer uma dessas instruções listadas abaixo.

0.1 + 0.2 == 0.3 // false

1 / 0 // Infinity
@brendomaciel
brendomaciel / percent_mask.js
Last active June 8, 2022 18:13
Máscara de porcentagem utilizando o plugin jQuery Mask Plugin (limita o valor máximo a 100)
$('#percent').mask('P', {
translation: {
'P': {
pattern: /[\d\.,]/,
recursive: true
}
},
onKeyPress: function(val, e, field, options) {
var old_value = $(field).data('oldValue') || '';
@brendomaciel
brendomaciel / uuid_mysql.sql
Created August 20, 2016 13:18
Trigger para gerar um UUID no momento da inserção de uma linha em 'table'
DELIMITER $$
USE `database` $$
DROP TRIGGER IF EXISTS `set_uuid` $$
CREATE DEFINER = CURRENT_USER
TRIGGER `set_uuid`
BEFORE INSERT ON `table`
FOR EACH ROW
BEGIN
@brendomaciel
brendomaciel / next_days.php
Last active September 22, 2016 03:15
Função para retornar um conjunto de datas de dias específicos $days — a partir da data atual — com tamanho $limit.
<?php
function get_week_by_date($date) {
$date = strtotime($date);
$week_position = date('w', $date);
// Seeking sunday
$sunday = ($week_position == 0) ? $date : strtotime('last sunday', $date);
@brendomaciel
brendomaciel / generate_friendly_url.php
Last active May 17, 2017 18:34
Função para converter uma string em uma URL amigável válida
<?php
function translate_similar_chars($buffer) {
$single_double = array(
'Æ' => 'AE',
'æ' => 'ae'
);
$buffer = strtr(
$buffer,