Crop the image using JavaScript

In my Angular 6 application I am making a file upload option and in preview the uploaded file needs to be displayed with auto cropping and auto resizing. I have tried the following, HTML: File select functtion: In the above I have tried the following with the reference of link https://jsfiddle.net/8jwq3cs7/ Before using the canvas … Read more

How to sort an object array by date property?

Simplest Answer More Generic Answer Or more tersely: Generic, Powerful Answer Define a custom non-enumerable sortBy function using a Schwartzian transform on all arrays : Use it like so: If your date is not directly comparable, make a comparable date out of it, e.g. You can also use this to sort by multiple criteria if … Read more

D3 Appending Text to a SVG Rectangle

A rect can’t contain a text element. Instead transform a g element with the location of text and rectangle, then append both the rectangle and the text to it: http://bl.ocks.org/mbostock/7341714 Multi-line labels are also a little tricky, you might want to check out this wrap function.

Remove not alphanumeric characters from string

Removing non-alphanumeric chars The following is the/a correct regex to strip non-alphanumeric chars from an input string: Note that \W is the equivalent of [^0-9a-zA-Z_] – it includes the underscore character. To also remove underscores use e.g.: The input is malformed Since the test string contains various escaped chars, which are not alphanumeric, it will … Read more