Tuesday, August 23, 2016

How to stream online radio via ubuntu terminal

I am a big fans of unix terminal. Today I found something interesting I can do with ubuntu terminal i.e. stream online radio via terminal. Here are the steps needed to stream your chosen radio via terminal

Install mplayer
Update your ubuntu repository to ensure that you use the latest update then install mplayer using apt-get
$ sudo apt-get update
$ sudo apt-get install mplayer
Find the IP address of the radio you want to listen. 
You might find it from anywhere, but I prefer to choose from https://www.xatworld.com/radio-search/. In the following screen capture, I show you when I was trying to find IP address for MQ FM (it is a moslem radio in Indonesia). You just need to supply the radio name, press "search", after it is found then you can just press "Find IP" button. Voila! Your radio IP address is there.



 Open your radio using mplayer
Now it's the showtime! You can play your radio now. Type this in your terminal
$ mplayer http://202.91.11.18:8000
Happy streaming! :D

Monday, May 16, 2016

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:
$ tar xzf jdk-8u92-linux-x64.tar.gz
Install JDK 
Install jdk into /usr/bin
$ update-alternatives --install /usr/bin/java java /home/arwan/Downloads/jdk1.8.0_92/bin/java 100

$ update-alternatives --install /usr/bin/javac javac /home/arwan/Downloads/jdk1.8.0_92/bin/javac 100

Check if java has been installed
$ java -version

Download Android Studio
You can download Android studio here.

Extract Android Studio
$ unzip android-studio-ide-143.2821654-linux.zip

Move all android-studio folder to /usr/local
$ mv /home/arwan/Downloads/android-studio /usr/local

Install Android Studio
$ /usr/local/android-studio/bin/studio.sh
Next, just follow the steps until your Android Studio is installed.

Friday, April 22, 2016

Make UnitTest Report Using HTMLTestRunner

I am a big fan of Python, and I am a big fan of TDD (Test Driven Development). The problem that I face for team development was that it is quite difficult to communicate the testing results to the team, because the results are in terminal so only us and God know :D

Fortunately, somebody out there know my problem and create this amazing HTMLTestRunner.py. This tool is very handy and very easy to use. It almost feels like you don't need to do anything. OK, here's one example on how we use HTMLTestRunner. Ah, forget it. Download HTMLTestRunner.py from this website, and put somewhere in your computer. Say in this example, I put in ~/Downloads/HTMLTestRunner folder

import unittest
import sys
_path = r"Downloads/HTMLTestRunner"
sys.path.append(_path)
import HTMLTestRunner

class TestDemo(unittest.TestCase):
    def testA(self):
        assert True
    def testB(self):
        assert False

class TestDemo2(unittest.TestCase):
    def testC(self):
        assert True
    def testD(self):
        assert True

def suite():
    suite = unittest.TestSuite()
    # TestDemo
    suite.addTest(TestDemo('testA'))
    suite.addTest(TestDemo('testB'))
    # TestDemo2
    suite.addTest(TestDemo2('testC'))
    suite.addTest(TestDemo2('testD'))

    return suite

if __name__ == "__main__":
    suite = suite()
    unittest.TextTestRunner(verbosity=2)
    output = open("results.html", 'w')
    runner = HTMLTestRunner.HTMLTestRunner(stream=output, title='Test Report', description='This is a test')
    runner.run(suite)

After you run it, boom... you will get a beautiful and informative report in html file. Here is the results in my example: