Month: January 2015

Simple javscript development using http-server

When developing small javascript projects I find the overhead of configuring a
virtual host in Apache or nginx cumbersome. The http-server module in node.js allows
you to easily start a webserver within your project folder.

Make sure node.js is installed and install the following module:

npm install http-server -g

The -g option install the module as a global one, meaning that you can start the
webserver from every folder. You can now go to any folder you’d like and issue the
following command:

http-server

This will result in the following output:

Starting up http-server, serving ./ on: http://0.0.0.0:8080
Hit CTRL-C to stop the server

You can now access all files in the folder via http://127.0.0.1/ in your webbrowser.

More information on this module can be found on the http-server project page. There
are several configuration options for configuration the port, ip address, etc.

Leave a Comment

Mysql remove on update current timestamp property

The MySQL management tool I use automatically creates tables with column of the time ‘timestamp’ with the property
“ON UPDATE CURRENT_TIMESTAMP”. This property means that when a record is updated this column is automatically updated
to the current time. This behavior can be unwanted. You can check whether a column has this property by issuing a ‘desc’ command:

DESC `tag`

Which in this example will result in:

Field   Type    Null    Key Default Extra
id  int(10) unsigned    NO  PRI NULL    auto_increment
label   varchar(25) NO      NULL    
key varchar(25) NO      NULL    
specificDate    date    YES     NULL    ON UPDATE CURRENT_TIMESTAMP 

The solution to this problem is to redefine the column manually without specifying this special property. It is possible to specify
a different default value than ‘CURRENT_TIMESTAMP’.

ALTER TABLE `tag`
    CHANGE `specificDate` `specificDate` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP;

Based on stackoverflow.

Leave a Comment