Tuesday, July 14, 2015

Connecting via Remote host using postgresql

When the instance of postgres is inside vm and you are on the host machine with some stack such as Node, the scenario becomes as if connecting from a remote host. To make it possible, we have to make postgres listen to remote (all) hosts and also specify the IP of that host.
1. To add the ip to the allowed host list, edit /etc/postgresql/9.1/main/pg_hba.conf and add the lines
host all all 192.168.0.1/24 md5
where 192.168.0.1 is the IP of the host you want to connect from.
2. And to enable listening from remote hosts, edit the file /etc/postgresql/9.1/main/postgresql.conf and add the following line
listen_addresses = '*'
Credits http://www.thegeekstuff.com/2014/02/enable-remote-postgresql-connection/

Setting up Node with NVM

I always keep facing problems with Node. It just keeps pushing me around with it's numerous errors. So, lately I found out about NVM and tried it. Still had an issue with it. But finally got it up and running. Here are some important things to keep note of when attempting to install node using NVM.
1. The default installation directory of the NVM installer (provided in the repo readme) is ~/.nvm. I find this a bit problematic so I actually just clone the repo into /opt/nvm since I kind of stick to sudoing things when they need to be global for node and ~/.nvm isn't owned by root, I kind of like to keep it that way.
2. Now setting up the envvars is done using profile.d/nvm.sh. This could also be done using ~/.zshrc or ~/.zprofile but I like it this way. In whatever case the envvar setup script is like this
export NVM_DIR=/usr/local/nvm
source /opt/nvm/nvm.sh

export NPM_CONFIG_PREFIX=/usr/local/node
export PATH="/usr/local/node/bin:$PATH"
3. So it's basically done (setting up NVM, not node) but since to install anything via nvm I'll need sudo so I must (at least) source the /etc/profile.d/nvm.sh into root. So I just do
$ sudo su
# source /etc/profile.d/nvm.sh
4. Now for the installation of a node version
# nvm install 0.12
# nvm ls
The last one should be done from root because it creates a particular directory that $ can't create.
5. Now we can simply execute
$ nvm use 0.12

Credits:
http://stackoverflow.com/questions/11542846/nvm-node-js-recommended-install-for-all-users
https://www.digitalocean.com/community/tutorials/how-to-install-node-js-with-nvm-node-version-manager-on-a-vps
Found a nice article here: http://www.liquidweb.com/kb/how-to-install-node-js-via-nvm-node-version-manager-on-ubuntu-14-04-lts/

Adding profile.d envvars to zsh

This is an extremely simple task to accomplish. Since, bash uses the following code segment to source all the files under /etc/profile.d you just have to add this into your ~/.zprofile or /etc/zprofile (the former sounds like a much more flexible choice).
# The default umask is now handled by pam_umask.
# See pam_umask(8) and /etc/login.defs.

if [ -d /etc/profile.d ]; then
  for i in /etc/profile.d/*.sh; do
    if [ -r $i ]; then
      . $i
    fi
  done
  unset i
fi


Monday, July 13, 2015

When you can't log into Postgresql from Web Interface (Adminer etc.)

I ran into this problem earlier this week and left it until today, when I needed it work at all cost. Turns out it was a simple issue with the configuration file. Here's the process.

First of all, open the file /etc/postgresql/9.1/main/pg_hba.conf
Find the line : "local" is for Unix domain socket connections only
Below that line there is a line like this: local all all md5
Just change the last value to: peer
So the line now looks like: local all all peer
Now save the file (you need to be root)
Then restart the Postgresql process using the command: sudo service postgresql restart
Done.

Connect Rapoo MT750S with Linux (Tested on Manjaro)

 I bought this obvious copy of MX Master 2S in hopes of having the device switching functionality along with a lightweight body because I ha...