This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Found on https://stackoverflow.com/a/20097994/5394675 | |
function getUrlVars() { | |
var vars = {}; | |
var parts = window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, | |
function(m,key,value) { | |
vars[key] = value; | |
}); | |
return vars; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//addapted from here: //http://wbruno.com.br/expressao-regular/formatar-em-moeda-reais-expressao-regular-em-javascript/ | |
const convertToBrMoney = (value) => { | |
value = parseFloat(value);//force value to be a number | |
var int = parseFloat(value.toFixed(2).toString().replace(/[^\d]+/g, '')); | |
var tmp = int + ''; | |
tmp = tmp.replace(/([0-9]{2})$/g, ",$1"); | |
if (tmp.length > 6) | |
tmp = tmp.replace(/([0-9]{3}),([0-9]{2}$)/g, ".$1,$2"); | |
tmp = value < 1 ? value.toString().replace('.', ',') : tmp; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<head> | |
<!-- as três linhas abaixo são uma correção para que elementos semânticos HTML5 funcionem em versões antigas do Internet Explorer--> | |
<!--[if lt IE 9]> | |
<script src="https://cdn.es.gov.br/scripts/extensions/html5shiv/3.7.2/html5shiv.min.js"></script> | |
<![endif]--> | |
</head> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validaEmail (email){ | |
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email); | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[ | |
{ "label": "Acre", "id": "AC" }, | |
{ "label": "Alagoas", "id": "AL" }, | |
{ "label": "Amapá", "id": "AP" }, | |
{ "label": "Amazonas", "id": "AM" }, | |
{ "label": "Bahia", "id": "BA" }, | |
{ "label": "Ceará", "id": "CE" }, | |
{ "label": "Distrito Federal", "id": "DF" }, | |
{ "label": "Espírito Santo", "id": "ES" }, | |
{ "label": "Goiás", "id": "GO" }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function truncateString(str, len, append) | |
{ | |
var newLength; | |
append = append || ""; //Optional: append a string to str after truncating. Defaults to an empty string if no value is given | |
if (append.length > 0) | |
{ | |
append = " "+append; //Add a space to the beginning of the appended text | |
} | |
if (str.indexOf(' ')+append.length > len) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const strPtBrMoneyToNumber = value => { | |
if(!value){ | |
console.warn('strPtBrMoneyToNumber needs a value to be converted'); | |
return false; | |
} | |
value = String(value); | |
value = value.replace(/\./g, '#');//remove . e troca por # | |
value = value.replace(/,/g, '.');//remove a , e muda para . | |
value = value.replace(/#/g, '');//remove a # e muda para "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//utils.js | |
import React from 'react' | |
export function childrenWithProps (props) { | |
return React.children.map(props.children, child => { | |
return React.CloneElement(child, { ...props }); | |
}); | |
} | |
//------ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//found on https://snipplr.com/view.php?codeview&id=10958 | |
$date = date("Y-m-d"); | |
$date = strtotime(date("Y-m-d", strtotime($date)) . " +12 month"); | |
$date = date("Y-m-d",$date); | |
echo $date; | |
Other examples | |
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 day"); | |
$date = strtotime(date("Y-m-d", strtotime($date)) . " +1 week"); | |
$date = strtotime(date("Y-m-d", strtotime($date)) . " +2 week"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$str = '123 - *&ˆ%$#@ T+=esteJhon#4255%%'; | |
$newStr = preg_replace('/[^[:alnum:]-]/','',$str); |