Wednesday, September 28, 2016

Modify and build your own SikuliX

In this tutorial, I show steps to modify and edit sikulix under OSX environment. This should not be different with other *nix environment. However, for windows environment, you may need to adjust yourself.

Modify your code

  • Clone from the repository
  • Open the repository as maven project in netbeans. You can easily use this button to open the project open
  • You will see that the cloned project appeared in open windows like the following
  • Open the project. It will be like this
  • Modify any part you want to modify
  • Clean and build the maven project. If you open other sub project of sikulix, make sure that you clean and build only the main sikulix maven project

Create Installer

Go to File Finder in the repository folder. You will see one file named runSetup. Using your terminal and cd to the folder and run the setup.

$ runSetup

It will bring you to SikuliX installation. Please remember that if you build yourself, ALWAYS do it in offline mode, means that you are not supposed to download anything during the installation. In other words, because SikuliX will need some packages/libraries, before installing SikuliX using your own build, you MUST install SikuliX in your computer by running normal build first. You can download the normal build here

Back to runSetup. You will see SikuliX installation window as follows

Before you continue, please pay attention to in this folder part. That part shows you where you can find your new build. To make myself clearer, I mean this part

It shows me that I can find the build in /Users/arwankhoiruddin/Library/Application Support/Sikulix/SikulixSetup folder

Then follow the instructions carefully. I repeat once more, please do not download anything during this installation.

Now go to SikulixSetup folder. You will find your new and fresh build there

Just move or copy SikuliX to /Applications folder and voila! Your newly build sikulix is ready to use

Thursday, September 8, 2016

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.

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:

Thursday, April 21, 2016

Import Python Script to SikuliX

When we need to import python script into sikulix workspace, here is one of the way to do:

1. Import sys
2. Append the path to the script into sys.path
3. Import your python script

Here is an example

import sys

sys.path.append("/Users/arwankhoiruddin/Downloads/python_packages/HTMLTestRunner")

import HTMLTestRunner

However, it has some limitations. You should refer to this document: https://answers.launchpad.net/sikuli/+faq/1114

Monday, April 11, 2016

Get Operating System used by SikuliX

If we write SikuliX code to check app on different operating system, we may need to define characteristic for each OS (e.g. image library or specific code). To check it, we can use built-in SikuliX script. Following is an example of OS checking

if Settings.isWindows():
    print "I am running on Windows"
elif Settings.isLinux():
    print "I am running on Linux"
elif Settings.isMac():
    print "I am running on Mac"

That's it. Hope it helps.

Thursday, April 7, 2016

Make vi appearance to be "real programming IDE"

"why not just use IDE or something like gedit?"

I had that question long ago and that made me stick to GEdit and other IDEs. However, when I have to do some works on files in server, I just realise that I have to familiarise myself to command-based editor. And, that's the beginning for me to know vi.

When I open it, the appearance is so boring. No line number, no syntax color. So, I decided to make at least that two things to make vi to be IDE like. Hahaha... Here's what I did:

$ vi ~/.vimrc

then type these lines in vimrc file

set number 

syntax on

colorscheme desert

====
set number will add line number on the left part of vi

syntax on will add colour of the syntax

colorscheme desert will set the colour scheme to be "desert"

That's it. I hope I can add some more customization of vi in the future. I feel that I am falling in love for the second time. Oh, vi... I love you.