“Possibly unhandled rejection” when closing ngDialog

 
 

Found my solution at: https://github.com/angular/material/issues/10369

When using the openConfirm function use:

TypeScript:

ngDialog

.openConfirm(dialogOptions)

.catch(function dialogCloseErrorCallback(reason: any) {

        // ngDialog v1.4.0 throws an exception, when closing the dialog with reason “undefined”.

        // Prevent this error:

    if (reason !== undefined) {

        throw
new Error(`Error when closing the dialog: [${reason}].`);

    }

});

 

When using open, use:

 

const openResult = self.ngDialog.open(dialogOptions);

if (openResult.closePromise) {

    openResult.closePromise.catch(function dialogCloseErrorCallback(reason: any) {

            // ngDialog v1.4.0 throws an exception, when closing the dialog with reason “undefined”.

           // Prevent this error:

        if (reason !== undefined) {

            throw
new Error(`Error when closing the dialog: [${reason}].`);

        }

    });

}

Allow *.css, *.js and *.html from the MVC 5 Views map

 

If you want to allow static content to be served from the asp .net MVC 5 views folder, just added the web.config in this folder and change path=”*” to path=”*.cshtml”.

https://stackoverflow.com/questions/17949460/how-do-you-request-static-html-files-under-the-views-folder-in-asp-net-mvc

 

<system.webServer>

<handlers>

<remove
name=BlockViewHandler/>

<add
name=BlockViewHandler
path=*.cshtml
verb=*
preCondition=integratedMode
type=System.Web.HttpNotFoundHandler />

</handlers>

</system.webServer>

Fix: TypeScript error Module ‘…’ has no default export

 

When I compiled my TypeScript project I got the error: [ts] Module ‘”c:/dev/am/common/element/after-visible”‘ has not default export:

 

This was caused by the fact, that I forgot to surround “afterVisible” with “{ }”.

The contents of the after-visible.ts module was:

 

/**

* Check the DOM repeatedly to see if the given element is visible, when element is visible call given function.

*/

export
function afterVisible(selector: string, fn: (element?: HTMLElement) => void, interval: number = 10, retryCount: number = 30): void {


const element = <HTMLElement>document.querySelector(selector);


if (element) {


const elementIsVisible = element.offsetWidth > 0 && element.offsetHeight > 0;


if (elementIsVisible) {

fn(element);


return;

}

}

 

setTimeout(function afterVisibleSetTimeoutElapsed() {


if (retryCount === 0) {


if (console) {

console.log(`Element ‘${selector}‘ does not exist or was not visible.`);

}

} else {


// Try again

afterVisible(selector, fn, retryCount – 1, interval);

}

}, interval);

}

 

 

So when you want to use the function afterVisible in an other function you will have to import it like so:

 

import { afterVisible } from
“./after-visible”;

 

function focus(element: HTMLElement) {

element.focus();

}

 

/**

* Check the DOM repeatedly to see if the given element is visible, when element is visible focus it.

*/

export
function focusAfterVisible(selector: string, interval: number = 10, retryCount: number = 30): void {

afterVisible(selector, focus, interval, retryCount);

}

 

 

 

 

 

Git / Bitbucket – The remote end hung up unexpectedly – Early EOF – index-pack failed at exactly 1GB

 

Suddenly my repository failed to clone:

git clone https://myuser@myurl.nl/scm/myproject/myrepo.git

Cloning into ‘myrepo’…

remote: Counting objects: 332184, done.

remote: Compressing objects: 100% (59662/59662), done.

fatal: The remote end hung up unexpectedly020.57 MiB | 9.89 MiB/s

fatal: early EOF

fatal: index-pack failed

 

It failed at exactly 1GB.

I found the fix at: https://community.atlassian.com/t5/Bitbucket-questions/My-git-clone-stops-at-1GB/qaq-p/70773

 

It was caused by a limit in nginx reverse proxy, after increasing the limit to 2GB I could clone again.

See: https://www.scalescale.com/tips/nginx/optimizing-nginx-for-serving-files-bigger-than-1gb/

 

 

 

 

Uncaught SyntaxError: Unexpected token in JSON at position 30 with escaped unicode character

 

When you execute the JavaScript code:

JSON.parse(“\”This is a unicode character: \u0007\””)

in a browser you will get the error:

Uncaught SyntaxError: Unexpected token in JSON at position 30
     at JSON.parse (<anonymous>)
     at <anonymous>:1:6

I fixed this by altering the C# code that returned the JSON.


public
static
class
MvcHelper

{


public
static
ActionResult ConvertToJsonActionResult(object data)

{


var content = ConvertToCamelCaseJsonString(data);

content = RemoveEscapedUnicodeCharactersFromString(content);


return ConvertStringToJsonContentResult(content);

}

 


private
static
string ConvertToCamelCaseJsonString(object data)

{


var serializationSettings =


new
JsonSerializerSettings

{

ContractResolver = new
CamelCasePropertyNamesContractResolver()

};


return
JsonConvert.SerializeObject(data, serializationSettings);

}

 


private
static
ContentResult ConvertStringToJsonContentResult(string content)

{


return


new
ContentResult()

{

Content = content,

ContentType = “application/json”,

ContentEncoding = System.Text.Encoding.UTF8

};

}

 


private
static
string RemoveEscapedUnicodeCharactersFromString(string content)

{


var regex = new System.Text.RegularExpressions.Regex(@”\\+[uU]([0-9A-Fa-f]{4})”);


return regex.Replace(content, string.Empty);

}

}

 

Then you can convert your C# ViewModel to a Json ActionResult:

[HttpPost]


public
ActionResult WizardData(int taakId)

{


var model = new
MyViewModelViewModel();

 


return
MvcHelper.ConvertToJsonActionResult(model);

}

 

 

 

 

 

 

 

 

Microsoft Word 2016: Word cannot register your account. The provider where you are trying to publish is unavailable. Contact your provider for assistance.

 

I was getting the error: “Word cannot register your account. The provider where you are trying to publish is unavailable. Contact your provider for assistance.”

This was caused by me forgetting to add ” /xmlrpc.php” to the end of the url.

So if you want to register a blog “https://my.blog.com” in Word 2016, then you should use the url “https://my.blog.com/xmlrpc.php ”