Skip to content

Instantly share code, notes, and snippets.

class BrazilRegion
{
constructor() {
this.States = [
{
Uf:'RO',
Name:'Rondônia'
},
{
Uf:'AC',
using System;
using System.Configuration;
using System.Web;
namespace Custom.Helpers.Common
{
public static class Cookie
{
private const string CookieSetting = "Cookie.Duration";
private const string CookieIsHttp = "Cookie.IsHttp";
@fjcunha
fjcunha / xmlToJson.js
Created September 4, 2018 22:50 — forked from chinchang/xmlToJson.js
Function to convert XML to JSON
// Changes XML to JSON
// Modified version from here: http://davidwalsh.name/convert-xml-json
function xmlToJson(xml) {
// Create the return object
var obj = {};
if (xml.nodeType == 1) { // element
// do attributes
if (xml.attributes.length > 0) {
@fjcunha
fjcunha / Format_Date_Input.js
Created May 11, 2017 12:49
Input mask when not work in sony, samsung devices.
function unmask(val) {
return val.replace(/\D+/g, '');
}
function formatDate(ev) {
console.log(ev.value);
var cleanText = unmask(ev.value);
var result = cleanText;
if (cleanText.length > 2) {
@fjcunha
fjcunha / Validate_cpf_cnpj
Created September 27, 2016 15:41
jQuery validator methods to validate cpf and cnpj
jQuery.validator.addMethod("cnpj", function (value, element) {
var numeros, digitos, soma, i, resultado, pos, tamanho, digitos_iguais;
if (value.length == 0) {
return false;
}
value = value.replace(/\D+/g, '');
digitos_iguais = 1;
//function to prepare the youtube embeded Url to use in iFrame src
$scope.trustSrc = function(src) {
var url = src.replace("watch?v=", "embed/");
url = src.replace("youtu.be/", "youtube.com/embed/"); //if cpied link by youtube app
return $sce.trustAsResourceUrl(url);
}
//validate a youtube Url
$scope.validateYoutubeUrl = function (url)
{
@fjcunha
fjcunha / calcule_distance_meters.txt
Last active September 27, 2016 15:39
Function to calcule distance in meters
public String calculeDistance(){
String distance = null;
double earthR = 6371;
double lati = Math.PI/180*(mMyLatitude - mPoi.getPoiLatitude());
double longi = Math.PI/180*(mMyLongitude - mPoi.getPoiLongitude());
double a =
Math.sin(lati/2) * Math.sin(lati/2)+
Math.cos(Math.toRadians(mPoi.getPoiLatitude())) * Math.cos(Math.toRadians(mMyLatitude)) *
Math.sin(longi/2) * Math.sin(longi/2);
@fjcunha
fjcunha / PointsDistance.txt
Created May 27, 2016 17:55
Formula to calcule Distance between two geoPoints
SQRT(
POW(69.1 * (latitude - [startlat]), 2) +
POW(69.1 ([startlng] - longitude) * COS(latitude / 57.3), 2)) AS distance
FROM TableName HAVING distance < 25 ORDER BY distance;