Syamsul's Blog

A place to breathe

Wednesday, July 19, 2017

Using Angular Generator

Using Angular Generator is easy.

Since I like to work locally, I use "--save-dev" option. if you want to install it globally, replace "--save-dev" with "-g"

Here the steps.

1. npm install grunt-cli bower yo generator-karma generator-angular --save-dev
2. yo angular
3. npm install karma 

Now you should be able to run grunt:

> grunt
> grunt serve

It is now published on http://localhost:9000


Monday, February 20, 2017

The all powerful Shebang

When you write scripts, often times, you'll see the following line at the top:


Now what is this?

This line allows you to run your script as the executable, without invoking the interpreter. For example, if I write a python script called, I will need to run it this way:

%> python 

change the permission and add the shebang line, will allow you to run it this way:

%> chmod +x
%> ./ 

if you want to run it in the background, then call the no hangup:
%> nohup ./ 

It will run itself doing its thing. Time to go to sleep while waiting for it to finish.

Wednesday, February 15, 2017

Changing NPM default module folders

When you install NPM on Linux, it will install into the root location by default. Often times, it could cause trouble if you want to modify the node_modules. 

To know where the node_modules are going to be installed globally: 

%> npm config get prefix

Now, I don't want to play around with the '/usr' permission because it is a standard OS directory. Trying to modify some stuff for node and have to deal with the top root directories is just not worth it. 

Now, change the NPM prefix: 

%> npm config set prefix=$HOME/.node_modules_global

so test it now: 
%> npm config get prefix

You should see that it list :

Change the path inside your .bash_profile: 
%> export PATH="$HOME/.node_modules_global/bin:$PATH

OK, now update your environment: 
%> source .bash_profile

Try installing an NPM just to check whether the global works: 
%> npm install npm --global
%> npm --version 

You should see your version changes from previously because it is now getting the latest npm.

Thursday, February 9, 2017

Python - why you should give it a try

I have programs written in Perl. Whenever I revisited the code, I've forgotten what I've written, so I would stare at some of these variables for a few minutes before I remember. I have a line of code that
I use the spaceship operator : ' <=> ' . I love it. But whenever I come back to this, I was like. Oh man, what is this. ??

So somehow a colleague of mine have written some Python and got stuck on some issues. In order to help him, I have to learn Python.  So i decided to rewrite a portion of the my Perl code to Python. The result is... wow, efficiency. !

I was thinking. Why I wrote so fast on Python? Hmmm... Then I realize a few things:

1. There's no curly brackets { }. So I don't have to worry about missing brackets.
2. Semicolon ';' is optional. So being lazy, I just skip the semicolon
3. Strong community support. Packages are all in PIP . Getting a package is as simple as running
    pip install  package_name
4. Works well on both Windows and Linux.

So far I'm happy with Python. I probably use more and more of it.

Saturday, January 7, 2017

Welcome to 2017!

Hi there, welcome to 2017

Life is full of surprises. Let's make full of it.

I don't really know much what to expect on 2017. I guess my first top priority is to fix my ailing guitar and sharpen my guitar skills. It's been a while. My skills are as rusty as my guitar. I also need to buy a new guitar too.

How about programming? Perhaps the biggest deal is database. Somehow I think it comes to a point that I need to master it.

I probably get a brand new spectacles. Seems like the power is going up on the right side.

How about traveling? Not  really in my priority but i guess I need to do some trips sometime in the middle of the year. Destination ? Don't know yet.

Living in this moment is the best thing. Everything else is a bonus.

Wednesday, December 21, 2016

Installing Postgres on Red Hat

By default, Red Hat installs Postgres. But surprisingly, the Postgres cannot be started by default. I guess it's not Red Hat's issue, but it's Postgres install issue. 

Here's the fix for all you care: 

1. create the data folder: 
    sudo mkdir -p /var/lib/pgsql/data
2. change ownership of the folder to user postgres
    sudo chown postgres /var/lib/pgsql/data
3. logon to user postgres: 
    sudo -i -u postgres
4. create the db: 
    initdb -D '/var/lib/pgsql/data'
5. start the db! 
    sudo service postgresql start

You're welcome. 

Saturday, October 1, 2016

How to point your git branch to remote

Often times, you want to point your Git your HEAD to the remote branch other than master. So all you need to do is to do this:

%> git checkout -b my_local_branch remote/origin/my_remote_branch 

And you are now pointing to the local branch pointing to your remote branch !

(Of course, I assume you know what Git is).

About Me

I'm currently a software engineer. My specific interest is games and networking. I'm running software company called Nusantara Software.