Skip to main content

Posts

Showing posts with the label tips

Some useful SSH Commands

Install SSH Server in Ubuntu sudo apt-get install openssh-server Run SSH Server sudo service ssh restart The output will be like * Restarting OpenBSD Secure Shell server sshd [ OK ] Check SSH Status ps -ef |grep "sshd" The output will be like hduser@d1:/hadoopSetup$ ps -ef | grep "sshd" root 125 0 0 02:35 ? 00:00:00 /usr/sbin/sshd hduser 138 79 0 02:45 pts/2 00:00:00 grep --color=auto sshd

Tips for cheap overnight car parking for your flight from KLIA or KLIA2

If you want to travel from KLIA or KLIA2, the parking fee for overnight parking in the airport is just crazy. In KLIA2, the first night will be 42 MYR. After that, it will be reduced to 21 MYR. Even after reduced, the fee is still very very very very very expensive. I will prefer to spend the money to buy some foods. 21 MYR equals to two or three times meals. Hahaha OK. So where you should put your car when you travel from KLIA or KLIA? I found some answers, but for myself, I prefer to park my car at Salak Tinggi Station. In Google Maps, you can find the coordinate from this link: https://goo.gl/maps/WWSdj2ZiTN22 Previously it was so cheap to park in Salak Tinggi. Only 3 MYR per night. However, now they increase the fee to 3 MYR for parking during the day and 8 MYR for overnight parking. However, 8 MYR is not that much compared to 21 MYR. Right? OK. So after parking the car, how can we go to KLIA or KLIA2? The first KLIA Transit train from KL-Sentral to KLIA2 st...

Mininet/Containernet Problem: Exception: Error creating interface pair (s2-eth5,s3-eth1): RTNETLINK answers: File exists

If you did not shut down the previous running mininet/containernet network (e.g. if you lose your connection to remote server), you will got the following error when you try to rerun your mininet network Traceback (most recent call last): File "./mynet.py", line 31, in <module> net.addLink(d2, s1) File "build/bdist.linux-x86_64/egg/mininet/net.py", line 403, in addLink File "build/bdist.linux-x86_64/egg/mininet/link.py", line 430, in __init__ File "build/bdist.linux-x86_64/egg/mininet/link.py", line 474, in makeIntfPair File "build/bdist.linux-x86_64/egg/mininet/util.py", line 202, in makeIntfPair Exception: Error creating interface pair (d2-eth0,s1-eth2): RTNETLINK answers: File exists In order to solve the problem, you need to clean up the previous running topology by using the following command sudo mn -c It will clean up all your cache. It will be something like this $ sudo mn -c *** Re...

Run docker without sudo

By default, you have to run docker using sudo . When you try to run it without sudo, you will get $ docker images Got permission denied while trying to connect to the Docker daemon socket In order to run without sudo, you will need to do the following steps Add the docker group if it does not already exist sudo groupadd docker Add the user to the docker group. If you want to add the current user, you can just use this sudo gpasswd -a $USER docker If you want to add, say user user1 , then you should just do sudo gpasswd -a user1 docker After you do the above steps, log out and now you can run docker without sudo .

Write Python Code to Send Email from Gmail

sendmail In this tutorial, we will write python code to send to multiple emails. Followings are the scenario: Emails will be listed in a text file The Python code will read the emails and send email to each address The email used is gmail Allow Less Secure App You must allow low secure app in your google account setting before you can run the code. In order to do that, go to https://myaccount.google.com/?pli=1 , navigate to sign in and security , scroll down and enable the allow less secure apps Write the Python Code Now we go to the most interesting part i.e. writing the code. Simplest Code We will start with a very simple code to send to one account #!/usr/bin/python import smtplib fromaddr = "mymail@gmail.com" frompass = "mypass" text = "this is the body" email = "targetmail@gmail.com" # login and send the email server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(from...

Customise Komode IDE command with python environment

Komodo is a lightweight and great programming IDE. Recently, I use the IDE to work on python. However, I got problem because I need to run the python from some virtual environments. To make it happen, this is what I did: 1. Create a shell script to run the virtual environment. For example we name the shell script runpyenv.sh, we may run the script with runpyenv.sh mycode.py. The code $1 will take the first input argument after the shell script name. source ~/arwanenv/bin/activate python $1 2. Now make the shell script to be executable sudo chmod +x runpyenv.sh 3. Now you put the shell script inside the command of your Komodo. It will be better if you make the file parameter to be automatic. Here is the command in your Komodo ~/runpyenv.sh %F Enjoy. Share your ideas in the comment if you have better idea.

How to Install Android Studio on Ubuntu 14.04

Followings are steps needed to install Android Studio on Ubuntu 14.04: There are some tutorials that suggest the installation using PPA. However, sometime it does not work because the PPA listed is no longer available or for any other reasons. In this post, I write manual way for installation. This way is much safer and more guarantee that it will work. Please let me know if you have any problem. Preparation If you run 64-bit ubuntu, install the following packages first. If you run 32-bit, you may skip this step and go to the next step $ sudo apt - get install lib32z1 lib32ncurses5 lib32bz2 - 1.0 lib32stdc ++ 6 Download JDK from Oracle You can download from their website. When I write this post, the download page is located here . However, they may move the download page. In case you don't find in that link, you can ask Google to find the download page for you. Extract JDK You can use Files Manager or use terminal. If you want to use terminal, you can use this command...

Tips Berwisata di Saat Liburan Panjang bagi Pembenci Macet dan Keramaian

Saya adalah seorang yang tidak suka pada macet dan tempat wisata yang terlalu ramai. Saya tidak suka macet karena macet bikin waktu serasa cuma habis di jalan. Saya tidak suka tempat wisata yang terlalu ramai karena tujuan berwisata adalah menikmati alam dan menikmati quality time bersama keluarga. Di tempat wisata yang terlalu ramai, waktu biasanya akan dihabiskan untuk nyari tempat parkir, nyari tempat kosong untuk berteduh atau bermain, dan susah sekali untuk bisa menikmati tempat wisatanya sendiri karena justru yang terlihat adalah ramainya. Pada liburan panjang seperti ini (natal dan tahun baru di akhir minggu ditambah dengan liburan anak sekolah), kondisi jalan dan tempat wisata mainstream sungguh sangat tidak menarik. Di mana-mana jalanan macet, dan di tempat-tempat wisata, terlalu banyak orang yang berkunjung. Untuk menyiasati, ada beberapa hal yang bisa dilakukan: 1. Jangan lewat jalan yang biasa dilewati orang. Carilah jalan alternatif (lebih baik gunakan aplikasi peta s...

Install Python 3 and use VirtualEnv (OS X)

Install xcode: $  xcode - select   -- install Install homebrew: $  ruby   - e   "$(curl -fsSL  https://raw.githubusercontent.com/Homebrew/install/master/install )" Create .bash_profile: $ touch ~/.bash_profile Put this line inside .bash_profile:  export  PATH = / usr / local / bin : $ PATH Install python3: $ brew install python3 Create virtual environment. To make it easily found, create it under home: $ cd ~ && pyvenv arwan Activate the virtual environment created: $ source arwan/bin/activate Now you can start working in the new virtual environment. Note that it is worth to look at requirements.txt to see required packages on certain projects.

Pull Older Version from Git

Clone the current repository: $ git clone Go to the cloned directory: $ cd Find the sha1 of the commit to pull. For stash, click on the commit and look at the address bar. It will be the last part of the url. For example, the sha1 for http://mystash.arwan.com/repos/arwanproj/commits/0b004fdb420838ca04c15b25ad2e0b66a5693963 will be  0b004fdb420838ca04c15b25ad2e0b66a5693963   Fetch the version based on the sha1 number found: $ git fetch origin Checkout: $ git checkout FETCH_HEAD

Understanding *args and **kwargs in Python

I need some time figuring out what is behind *args and **kwargs. Finally I understand it, so I want to share it with you here. First of all, you need to know that what you need to understand here is the asterix (*), not the "args" and "kwargs". So if you write f(*params, **oparams) and f(*args, **kwargs), they both will behave similarly. * is used to pass varied length of arguments. Here is an example on how to use * def test_args(a, *b): def test_args(a, *b): print "normal variable: ", a print "first argument: ", b[0] print "second argument: ", b[1] print "third argument: ", b[2] test_args('arwan', 1,2,3,4,5) From the example, "a" is single variable while "b" is varied length of argument. Thus, the first argument will be passed to "a" where the next variable will be passed to "b". Thus, all arguments (1,2,3,4,5) will be passed to "b" ...