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
<?php | |
function merge_white_spaces($string) { | |
// Remove multiple line breaks | |
$string = preg_replace("/[\n\r]{3,}|[\r\n]{3,}|[\n]{3,}|[\r]{3,}/", PHP_EOL . PHP_EOL, $description); | |
// Remove tabs | |
$string = preg_replace("/\t+/", "", $description); | |
// Remove multiple spaces (the character " " is used instead \s because the second removes line breaks too) |
String.prototype.limit = function(size, cutWord, suspensionPoints) { | |
var str = this; | |
cutWord = typeof cutWord == "undefined" ? true : cutWord; | |
if (typeof size == "number" && size > 0 && str.length >= size) { | |
str = str.substr(0, size); | |
if (!cutWord) { | |
str = str.substr(0, Math.min(str.length, str.lastIndexOf(" "))); |
<?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); |
DELIMITER $$ | |
USE `database` $$ | |
DROP TRIGGER IF EXISTS `set_uuid` $$ | |
CREATE DEFINER = CURRENT_USER | |
TRIGGER `set_uuid` | |
BEFORE INSERT ON `table` | |
FOR EACH ROW | |
BEGIN |