Showing posts with label Code. Show all posts
Showing posts with label Code. Show all posts

Wednesday, August 01, 2018

Angular find the version of CLI

Find version of the Angular CLI using the command

ng --version 

or

ng -v

C:\Users\xxx>ng -v


This will show the version

C:\Users\xxxx>ng -v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 6.1.1
Node: 9.11.1
OS: win32 x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.7.1
@angular-devkit/core         0.7.1
@angular-devkit/schematics   0.7.1
@schematics/angular          0.7.1
@schematics/update           0.7.1
rxjs                         6.2.2

typescript                   2.7.2

Angular - deploy your app in a sub folder

 

If you want to deploy your app in a sub folder you need to add the build flag --base-href

This will set the <base href> in the html.

eg: ng build --prod --base-href=/dist/my-app/



Example


C:\Users\xxxx\Documents\works\ng\my-app>ng build --prod --base-href=/dist/my-app/

Date: 2018-08-01T09:13:50.591Z
Hash: 54082fcc1c77e8124a32
Time: 56271ms
chunk {0} runtime.a66f828dca56eeb90e02.js (runtime) 1.05 kB [entry] [rendered]
chunk {1} styles.34c57ab7888ec1573f9c.css (styles) 0 bytes [initial] [rendered]
chunk {2} polyfills.2f4a59095805af02bd79.js (polyfills) 59.6 kB [initial] [rendered]
chunk {3} main.ca74553da7e3e55d6410.js (main) 171 kB [initial] [rendered]


Thursday, June 14, 2018

D3 tooltips - show tooltip in a different location

Sometimes you need to manually specify a target to act on. For instance, maybe you want the tooltip to appear over a different element than the one that triggered a mouseover event. You can specify an explicit target by passing an SVGElement as the last argument.

tip.show(data, target)

Check working example here 

The API for the above code is found here under Explicit targets

Wednesday, June 13, 2018

Get last element using D3

Method 1

You can use the selector :last-of-type to get the last element

var lastElement = parentObject.selectAll("rect:last-of-type");  


Method 2

Use selectAll and get the last element in array.

var lastElement = parentObject.selectAll("rect");
lastElement = lastElement[lastElement.length - 1]; // this will have the last element

Wednesday, May 16, 2018

Bulma - How to make text unselectable

Requirement: I want to restrict users selecting text in my website. How do I do this using Bulma

Use the class
.is-unselectable

See the Pen Bulma - make text unselectable by Kiran (@kiranvj) on CodePen.

Malayalam matrix screen

മലയാളം മാട്രിക്സ്

See the Pen Malayalam Matrix by Kiran (@kiranvj) on CodePen.

Bulma - left or right align an element

How to left or right align an element in Bulma

Use class .is-pulled-left to left align an element.

Use class .is-pulled-right to right align an element.


See the Pen Bulma - pull an element to right by Kiran (@kiranvj) on CodePen.

Sunday, May 13, 2018

Bootstrap - show text in a single link

To show text in a single line you need to added the Bootstrap class "text-nowrap"

Example
<span class="nowrap">Your text here.</span>

JavaScript - Check if object is empty

function isEmptyObject ( obj ) {
    var name;
    for ( name in obj ) {
        return false;
    }
    return true;
}

Friday, April 20, 2018

JavaScript set object key by variable

ES6

var key = "name";
var person = {[key]:"John"};
console.log(person); // should print  Object { name="John"}

Before ES6

var person = {};
var key = "name";

person[key] /* this is same as person.name */ = "John";

console.log(person); // should print  Object { name="John"}

Thursday, April 19, 2018

Give random colors to text in a page using D3

d3.selectAll("*").style("color", function() {
  return "hsl(" + Math.random() * 360 + ",100%,50%)";
});

Get Indian financial year based on date

This function lets you get the start and end date of Indian financial year based on given date. This can also be modified for US financia...