Installing pgAdmin4 (desktop mode) in Ubuntu

First install development package for compiling latest pscyopg2 package.

Note: make sure the version of postgresql server that will be remote using pgAdmin4 is 9.0 above.

sudo apt-get install python-dev postgresql-server-dev-9.5

Continue reading “Installing pgAdmin4 (desktop mode) in Ubuntu”

Advertisements

Bash: read file with ignoring new line

Usually i always read file in bash by iterating through for loop like following

 
for line in `cat /path/to/file`;do
   echo "Processing => $line"
done

but sometime the file that i need to open has special character that make mess every line in file that i read, for example if i open with command line editor such as vim the words within line looks line a normal one:
Hello this is a normal line
but when i use the normal for loop it will be like this

Hello
this
is
a
normal
line

After searching in google i found the solution in stackoverflow by using read command and the file the will be opened as stdin:

MACLIST='/etc/ethers'

DONE=false
until $DONE ;do
        read || DONE=true
        # ignore every thing that begin with shebang
        echo $REPLY | grep '^#' > /dev/null && continue

        MACADDR=`echo $REPLY | awk '{print $1}'`
        IPADDR=`echo $REPLY | awk '{print $2}'`

        # if there is no macaddr or ipaddr then ignore it
        if [ -z $MACADDR ] || [ -z $IPADDR ];then
                continue
        fi

        echo "$MACADDR => $IPADDR"
done < $MACLIST

The variable REPLY contains current line of loop process.

Decode Url Parameter

When i tracing some ajax activity from an apps that connected to Alfresco API like this

192.168.113.44%3A8080%2Falfresco%2Fservice%2Fapi%2Flogin%3Fu%3Domar%26pw%3Dkacangitem

Event though it still readable but sometime the url are more longer with ticket ID, i can encode the url with online tools such as this one but my friend told me it can be done with python.

from urllib import unqoute

target = &amp;quot;192.168.113.44%3A8080%2Falfresco%2Fservice%2Fapi%2Flogin%3Fu%3Domar%26pw%3Dkacangitem&amp;quot;
print unqoute(target)