sábado, 19 de maio de 2018

json reference cycle - from C# NewtonSoft JSON

This is more a JS problem than a Vue one - $ref/$id are non-standard JSON. NET syntax. Been a while since I’ve dealt with cyclical refs, but I think this is what I used last time: https://bitbucket.org/smithkl42/jsonnetdecycle - then store the decycled object graph in your Vue model

sexta-feira, 18 de maio de 2018

How to Get Query String Parameters with JavaScript

// Assuming "?post=1234&action=edit"
var urlParams = new URLSearchParams(window.location.search);

console
.log(urlParams.has('post')); // true
console
.log(urlParams.get('action')); // "edit"
console
.log(urlParams.getAll('action')); // ["edit"]
console
.log(urlParams.toString()); // "?post=1234&action=edit"
console
.log(urlParams.append('active', '1')); // "?post=1234&action=edit&active=1"
URLSearchParams
https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams


You can use URLSearchParams and this polyfill to ensure that it will work on most web browsers:
https://github.com/WebReflection/url-search-params/blob/master/build/url-search-params.js


https://davidwalsh.name/query-string-javascript

See
https://stackoverflow.com/a/50417160/194717
https://stackoverflow.com/a/50417160/194717
https://stackoverflow.com/a/12151322/194717

terça-feira, 15 de maio de 2018

Flurl custom Json settings

            Flurl.Http.FlurlHttp.Configure(settings =>
            {
                settings.JsonSerializer = new Flurl.Http.Configuration.NewtonsoftJsonSerializer(WebAPI.helper.serializerSettings);
            });

public static class helper
    {
        ///
        /// Utilize este arquivo helper.cs
        /// Atencao em todo o sistema deve usar esta mesma configuracao, Server e no Client,
        /// exemplo no Azure Function e no site SistemaMulti
        ///

        public static Newtonsoft.Json.JsonSerializerSettings serializerSettings = new Newtonsoft.Json.JsonSerializerSettings()
        {
            //Formatting = Newtonsoft.Json.Formatting.Indented,
            ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Serialize,
            PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.All,//????.Arrays,
            TypeNameHandling = Newtonsoft.Json.TypeNameHandling.All
        };
        public static string ToUTF8String(this System.IO.Stream se)
        {
            using (var reader = new System.IO.StreamReader(se, Encoding.UTF8))
            {
                string value = reader.ReadToEnd();
                return value;
            }
        }
    }

sexta-feira, 4 de maio de 2018

Azure Web App - Facebook OAuth redirect


https://login.microsoftonline.com/te/tsmulti.onmicrosoft.com/oauth2/authresp
https://sistemamulti.azurewebsites.net/.auth/login/facebook/callback

segunda-feira, 16 de abril de 2018

terça-feira, 3 de abril de 2018

The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF

I got this error when

sudo apt-get update

Reading package lists... Done
W: GPG error: https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY EB3E94ADBE1229CF
W: The repository 'https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial InRelease' is not signed.
N: Data from such a repository can't be authenticated and is therefore potentially dangerous to use.
N: See apt-secure(8) manpage for repository creation and user configuration details.



Use:



curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg