Angular extend base component

Source: https://stackoverflow.com/questions/49320759/angular-4-extend-base-component

Since base class doesn't need to be instantiated on its own, it's abstract class and doesn't need to have @Component decorator.
If it has dependencies, and there's a chance that constructor will be omitted in child classes and inherited, base class should have @Injectable decorator:
@Injectable()
export abstract class BaseComponent implements OnInit {
  constructor(public dep: Dep) {}

  ngOnInit() {}
}

@Component({
  selector: 'app-child',
  templateUrl: './child.component.html',
  styleUrls: ['./child.component.css']
})
export class ChildComponent extends BaseComponent {
  // dummy constructor can be omitted
/*
  constructor(dep: Dep) {
    super(dep);
  }
*/
}

JavaScript Date Input Format Default


There are generally 3 types of JavaScript date input formats:
TypeExample
ISO Date"2015-03-25" (The International Standard)
Short Date"03/25/2015"
Long Date"Mar 25 2015" or "25 Mar 2015"
The ISO format follows a strict standard in JavaScript.
The other formats are not so well defined and might be browser specific.

Get Date object from Moment

Source: https://stackoverflow.com/questions/17987647/moment-js-transform-to-date-object

Use this to transform a moment object into a date object:
moment().toDate();
Yields:
$(function(){
  setInterval(function(){
    var divUtc = $('#divUTC');
    var divLocal = $('#divLocal');  
    //put UTC time into divUTC  
    divUtc.text(moment.utc().format('YYYY-MM-DD HH:mm:ss'));      
    
    //get text from divUTC and conver to local timezone  
    var localTime  = moment.utc(divUtc.text()).toDate();
    localTime = moment(localTime).format('YYYY-MM-DD HH:mm:ss');
    divLocal.text(localTime);  
      
    $('#divThai').text(moment.tz('Asia/Bangkok').format('YYYY-MM-DD HH:mm:ss'));
    $('#divUsa').text(moment.tz('America/Los_Angeles').format('YYYY-MM-DD HH:mm:ss'));
  },1000);
});
Tue Nov 04 2014 14:04:01 GMT-0600 (CST)
var myDateObj = new Date(2011, 9, 16);
var now = moment(myDateObj);
#Now convert it back to date object
var newDateObj = new Date(now.format("YYYY-MM-DDTHH:mm:ssZ"));
This might be a delayed response.But, I think it can help others who still needs an answer.
To retrieve a native Date object from Moment, use .toDate()
You can directly get the Date object from Moment.

MySQL varchar case sensitive/insensitive

Source: https://dev.mysql.com/doc/refman/5.6/en/charset-collation-information-schema.html
https://www.stetsenko.net/2012/10/mysql-unique-case-sensitive-varchar/
https://stackoverflow.com/questions/18737805/mysql-case-sensitive-in-utf8-general-ci
https://stackoverflow.com/questions/10929836/utf8-bin-vs-utf-unicode-ci
https://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci

String columns in INFORMATION_SCHEMA tables have a collation of utf8_general_ci, which is case insensitive. However, for values that correspond to objects that are represented in the file system, such as databases and tables, searches in INFORMATION_SCHEMAstring columns can be case-sensitive or insensitive, depending on the characteristics of the underlying file system and the value of the lower_case_table_names system variable.


MySQL is case insensitive by default and normally it is more than enough. However one of my recent projects required a case sensitive varchar column with unique index. Latter would immediately trigger ‘Duplicate entry … for key …’ error for “the same” strings.
CREATE TABLE file (
  id INT AUTO_INCREMENT, 
  name VARCHAR(100) NOT NULL, 
  PRIMARY KEY(id),
  UNIQUE(name)
);
 
INSERT INTO file (name) VALUES ('test.txt'), ('test.TXT');
For example in the query above the second insert fails returning that error.
A way to address this is just to use a case sensitive collation (e.g. utf8_bin).

CREATE TABLE file (
  id INT AUTO_INCREMENT, 
  name VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL, 
  PRIMARY KEY(id),
  UNIQUE(name)
);

MySQL : Rename column

Source: https://stackoverflow.com/questions/30290880/rename-a-column-in-mysql

Use the following query:
ALTER TABLE tableName CHANGE `oldcolname` `newcolname` datatype(length);
The RENAME function is used in Oracle databases.
ALTER TABLE tableName RENAME COLUMN "oldcolname" TO "newcolname" datatype(length);
Notice the backticks used for MySQL, whereas double quotes are used for Oracle's syntax. Also note that MySQL 8.0 might not accept backticks. In that case, execute the query without backticks and it will probably work.

Nodejs express: multiple route names on the same action

Source: https://stackoverflow.com/questions/15350025/express-js-single-routing-handler-for-multiple-routes-in-a-single-line

@Jonathan Ong mentioned in a comment above that using arrays for paths is deprecated but it is explicitly described in Express 4, and it works in Express 3.x. Here's an example of something to try:
app.get(
    ['/test', '/alternative', '/barcus*', '/farcus/:farcus/', '/hoop(|la|lapoo|lul)/poo'],
    function ( request, response ) {

    }
);

Disable click event outside of bootstrap modal area to close modal in angular

Source: https://stackoverflow.com/questions/47152988/disable-click-event-outside-of-bootstrap-modal-area-to-close-modal-in-angular-4

please add this config's in html. Hope it will help your problem.
<div bsModal #noticeModal="bs-modal" class="modal fade" tabindex="-1" role="dialog" 
    [config]="{backdrop: 'static',  keyboard: false}" 
    aria-labelledby="myLargeModalLabel"
    aria-hidden="true">

    <div class="modal-dialog modal-md">
        <div class="modal-content">
              Hello World
        </div>
    </div>
</div>

AH00035 permission denied

  sudo chmod 751 /home/ubuntu sudo chown -R ubuntu:www-data /home/ubuntu/genealogy-giapha sudo chmod -R 750 /home/ubuntu/genealogy...