Posts

Showing posts from May, 2016

How to execute a file in node js.

With a text editor, create a file called web-server.js, with the following contents:

var http = require('http');
var serv = http.createServer(function (req, res) {
    res.writeHead(200, { 'Content-Type': 'text/html' });
    res.end('<marquee>Debug Report</marquee>');
});
serv.listen(3000);

Run the file:

node web-server.js

Enable debugging in Firebase Android

You can enable debugging in Firebase using following code.

Firebase.getDefaultConfig().setLogLevel(Logger.Level.DEBUG); Output will be look like following snapshot.

05-14 02:32:11.089 6645-7531/com.aybits.discoversaints.discoversaints D/PersistentConnection: pc_0 - Listening on /saints/video:{}
05-14 02:32:11.089 6645-7531/com.aybits.discoversaints.discoversaints D/PersistentConnection: pc_0 - Adding listen query: /saints/video:{}
05-14 02:32:18.001 6645-7531/com.aybits.discoversaints.discoversaints D/PersistentConnection: pc_0 - unlistening on /saints/video:{}
05-14 02:32:18.001 6645-7531/com.aybits.discoversaints.discoversaints D/PersistentConnection: pc_0 - removing query /saints/video:{}
05-14 02:32:18.002 6645-7531/com.aybits.discoversaints.discoversaints D/PersistentConnection: pc_0 - Listening on /saints/video:{}
05-14 02:32:18.002 6645-7531/com.aybits.discoversaints.discoversaints D/PersistentConnection: pc_0 - Adding listen query: /saints/video:{}

Converting Density Independent Pixels (dp) to Pixels (px) in Android

Sometimes we need to convert density independent pixels(dip/dp) to pixels to set view properties like width or height. Here how it is done using Java.

Resources r = getResources();
    int px = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 300,       r.getDisplayMetrics());
    myEditText.setWidth(px);