When you write scripts, often times, you'll see the following line at the top:
#!/usr/bin/python
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 blabla.py, I will need to run it this way:
%> python blabla.py
change the permission and add the shebang line, will allow you to run it this way:
%> chmod +x blabla.py
%> ./blabla.py
if you want to run it in the background, then call the no hangup:
%> nohup ./blabla.py
It will run itself doing its thing. Time to go to sleep while waiting for it to finish.
A place to breathe
Monday, February 20, 2017
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
/usr
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 :
/path/to/home/.node_modules_global
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.
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
4. Works well on both Windows and Linux.
So far I'm happy with Python. I probably use more and more of it.
Subscribe to:
Posts (Atom)
About Me
- syamsulhasran
- I'm currently a software engineer. My specific interest is games and networking. I'm running software company called Nusantara Software.