Menu bars

Drop Down MenusCSS Drop Down MenuPure CSS Dropdown Menu

Friday, 24 June 2016

Understanding Node+Express application flow.

As installation has explained in the last article now we want to start with the project and structure. It is very important to understand the proper directory structure of the node app since we need to map the relevant files in the right directory to align with the MVC pattern that node follows. I have found out the following article which explains the node directory structure perfectly.

Check this article

Confused over export and require ? 


I was confused too much on export, module and require stuff of nodejs until i have came across the following article which deals with the same. what i have taken from the article is that, a file is considered as a module in nodejs and if you want to use it in another file(module) then you need to export it. Simple stuff !!

Router everywhere !!


If you are start making Restful webservices we need to use routers very frequently to create different routes for our RestWebservices. They have introduced mini express in router and if you want to understand how the router works and the different functions that can be done in router like params,use,get etc.



Understanding the basic components using in the app.js


It is essential to know the components that we are using in our landing file that is app.js and their role in this particular context. So i just thought of going through each package that we are using in the app.js file.

Path - Just to know 


Path is the package  to deal with all the directory level operations to be done. __dirname gives you the current working directory and you can do many other operations like join(), basename() etc.

Error handling in Node


Error handling is very important feature every application should have. It will make the application maintainable and debuggable. The Nodejs style of error handling is little different which involves middle-wares which will make your job damn easy. check the links below.


Logging

Logging can be one of the important thing is to be done with any software application. Winston is one of the finest logger that you can use for Nodejs. Read more 

All about passing the data in Nodejs routes

Passing the data in the routes are very important to deal with the flexibility of the microservcie framework. As Node stands out as an exceptional framework to create microservices it is important to know how to pass the data.

This article talks about each and everything about passing the data between routes. 









Thursday, 23 June 2016

Nodejs installation and basics

Nodejs is getting popularity as Javascript can be used as a complete stack and JS is  the only language that you need to know before creating a web application. Yeah nothing else.

My requirements are like to install the nodejs in a unix based server, preferably centos or ubuntu. simple commands will help you to install nodejs. The following link will help you to install node perfectly to your centos system.

Please check this link 

One of the issue that i faced just after installing the nodejs was my command prompt was not understanding the node or npm as commands. What i understood is that the installation was installing node and npm to /usr/local/bin/ location. But the command line understand the binaries in the /usr/bin location. So we need to map this using synlink.

ln -s /usr/local/bin/node /usr/bin/node
ln -s /usr/local/lib/node /usr/lib/node
ln -s /usr/local/bin/npm /usr/bin/npm
ln -s /usr/local/bin/node-waf /usr/bin/node-waf

This link will help you to understand the what is going on.

Now install express with npm and the same synlinking we need to do for each package that we create.

 ln -s /usr/local/bin/express /usr/bin/express
 ln -s /usr/local/bin/node-supervisor /usr/bin/node-supervisor
 ln -s /usr/local/bin/supervisor /usr/bin/supervisor
 ln -s /usr/local/bin/n /usr/bin/n

It will be good to go through this link before we start installing new packages. This will help you understand how to install a npm package.

 n stable

it will be good if we install any daemon based package to manage our nodejs app. So it will take care of handling the nodejs instance running.

 npm install forever
 npm install forever-monitor
 ln -s /usr/local/bin/forever /usr/bin/forever

Now you can start nodejs daemon in forever as -
   forever start /tmp/node/UpgradeChecker/app/bin/www


If you want to make this as a custom service then check this link. If you do then you can start your app like,
 service nodeapp start






Python text to speach

It is a good comparison of various tools available for text to speech :

http://fossforce.com/2015/04/an-in-depth-look-at-text-to-speech-in-linux/

Setting the mbrola -- http://askubuntu.com/questions/554747/how-to-install-more-voices-to-espeak

Worth checking mary - https://sites.google.com/site/guenterbartsch/blog/maryttspythonandpulseaudio

Example python code -http://stackoverflow.com/questions/6772710/function-doesnt-work-the-second-time-its-called-in-a-thread-pyttsx-module

linux processes - https://idea.popcount.org/2012-12-11-linux-process-states/

Looking for natural sounds ? -http://askubuntu.com/questions/21811/how-can-i-install-and-use-text-to-speech-software



Sunday, 25 October 2015

Issues after live

25 Oct 2015

This made me tensed, suddenly the site went down and i was shocked. Tried to do everything then finally found this this discursion in the drupal site. Problem was with database disconnected. So restarted the service and everything started working.

26 Oct 2015

Wanted to redirect to same page after login and got help from this page. and worked perfect !

Monday, 19 October 2015

Digital Ocean Server admin basics

It is always essentials to get all the basics of the server admin if you are going to host a website by your own. Great !! Lets start with the very basics.

What i am going to use as a host service is digital ocean which will provide you VPS in a cloud style that is pay whatever you use. But after i create my cloud instance how can i access the remote server ? Yeah SSH (Secure shell) !!

This video is a very quick introduction to what is SSH ?


This one shows how to setup a ssh server


Now lets go in the digital ocean way itself, I have found many articles in the digital ocean to how to manage the server.
  • After creating a droplet in the digital ocean we need to connect to that droplet via SSH, this article tell you how to do that.
  • Now we want to see how the server has to configure for the SSH, You can check out this wonderful tutorial for getting an overview of what is happening.
Here is the command that i have used.

From server to local 

rsync -azP User@X.X.X.X:/var/www/html/drupal/sites /var/www/html

From local to server

rsync -azP /var/www/html/sites  User@X.X.X.X:/var/www/html/drupal



But this video is simple and elegant, it shows that how to create a public-private keys and how to connect to your remote server.Awesome !!



And finally we need to make the site online, here is the details for initial setup to be followed in digital ocean.


GUI to manage the server

After few searches in the internet came to know about webadmin one of the GUI based application for managing the server. So that it will give easy access to each and everything and we need not do all the file edit from the server.Here is the tutorial tells you how you will do it.



Oh You have not done yet !! want to add a domain name to the droplet that we have created ? So simple in digital ocean - Refer this tutorial to do that


FIle permissions

You might come across the permission problems in the system. Here is the stack answer deals with that in detail



Friday, 16 October 2015

Drupal 7 issues that i have faced and how did i solved it !!

Sept 28 2015

  • Wanted to automatically upload the image when it chose from computer
Solved it by using the module AutoUpload - Here is the link  

  • Want to use custom view for node/add/form for authenticated users.
After a bit of research landed on this link and worked like a charm

Sept 29 2015


  • Remove the messages after few seconds in my site
A simple javascript trick will do it for you - here

  • Use different page layouts for different urls 
After a few searches and a hour of trying out various option landed in here

Oct 12 2015

Stumbled upon the problem with migration of my site. I have taken the sql dumb and tried to load it into the new server. but i had some problem with cache, it was taking the older site path and i posted a question in the stackoverflow for drupal and got the answer that i have to change the values in registry and registry_table tables. You can find the question here .


Oct 16 2015


Faced a very annoying problem with ajax comments. It was showing "A parsing or network error has occurred." when i was trying to click on any of the poll actions. Checked this answer in drupal.org and started checking the developer console in the chrome and came to know about the php error "E_CORE_WARNING Error in file  Unknown  at line 0: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20121212/msql.so' - /usr/lib/php5/20121212/msql.so: cannot open shared object file: No such file or directory drupal"

Checked this answer in stack overflow after that and commented the extesnion in the php.ini file in the apache2.


Oct 19 2015

I was in the last phase of migrating my application and i have came across that the update script is not running properly and it is stopping in between the "pending updates" and the updates were not running. After a day i have came across the this answer from the stack exchange. I thought of trying this out by changing the corresponding updates in the database manually. after that everything worked perfectly. Great start for the day.




Sunday, 11 October 2015

Migrate a drupal site from localhost to server

Here is a wonderful video tutorial from scott from level of tuts - See here

But may be sometime you need to change the size of the file that can be uploaded to the website and that you can change by tweaking the php.ini file. The detailed steps to follow is here


  • If you want to change file upload size then go for this
  • Migrating common problem, worth reading. Awesome guidelines, Must read - This one