# Category Archives: Featured Articles

## CodeIgniter and XMLRPC

### What are we going to do?

We’ll mimic what we already achieved in CodeIgniter and NuSOAP post using XMLRPC method.

So, we’ll create two endpoints, one is for getting a CD info (function name : getCdInfo) and the other is for getting all of CDs listed (function name : getCds).

We’ll still implement all of our function inside Welcome controller. The difference is that the registration process is placed inside index() function while the implementation is outside index() function but still within Welcome class.

### The Server

Here’s the configuration and registration process inside index() function:

Notice how I defined the endpoint name and register it. So, getCdInfo endpoint will be implemented in Welcome controller and getCdInfo function, while getCds endpoint will be implemented in Welcome controller as getCds function.
Now, here’s the implementation:

getCdInfo takes one parameter, so, we need to pass $request as getCdInfo function parameter while getCds function doesn’t take any parameter, so we omit it. Pay attention on getCds function, you’ll learn how I implement an XMLRPC endpoint that return an array of array (a data table). ### The Client Same as CodeIgniter and NuSOAP, for simplicity, we’ll implement the client as part of Welcome controller. Here’s the client code: getCdInfo call will output something like this: While getCds will return something like this: As you can see, the output of XMLRPC method is the same as NuSOAP method. No fixing needed! Here’s the complete source code of our controller: ## CodeIgniter and NuSOAP ### What are we going to do? We’ll use NuSOAP to create a webservice using CodeIgniter and consume it using CI also. In this tutorial, we’ll use “cds” table from “cdcol” database bundled from XAMPP. “cds” table content looks like this: cds table content Download NuSOAP here : https://sourceforge.net/projects/nusoap/ Extract “lib” folder from nusoap-0.9.5.zip into your CI “application/libraries/”. We’ll create simple library warper for NuSoap. Now, enter your CI “application/libraries/” folder and create a new file named “Nusoap_library.php”. Here’s the content: We’ll use default controller from CI, i.e. Welcome.php. We’ll create two webservice endpoints: one for getting info about a CD based in it’s “id” and one for getting all of CDs. All of webservice data types definition, registration and implmentation will be placed inside Wellcome controller’s “__construct()” function. Here’s the complete code for “__construct()” function: The first step is loading the library and configuring your webservice: We’ll define a new data type for our CD info based on “cds” table structure: Now, our complex type that will hold list of CDs (array of CDs). After finished defining all needed data types, we’ll register all needed webservice endpoint. First endpoint is “getCdInfo” to get info about a CD based on it’s “id”. It takes one parameter (“id”) and return a “Cd” type. Second endpoint is “getCds” to get all stored CD in the “cds” table. It takes no parameter and return an array of CDs. Registration is finished, now onto the implementation. Here’s the code: Pay attention, that I’m using “get_instance()” in order to query the database because we can’t call “$this” inside these endpoint functions.
Next, we’ll edit the default “index()” function, replace it with these:

You may try accessing your webservice from your browser and see how it looks

WSDL schema

webservice description

### Now, some fixing!

Before accessing our webservice via a SOAP client, we need to fix NuSoap library. Open “application/libraries/lib/nusoap.php”, go to line 6132 and comment that line so it would look like this:

If you didn’t do this fixing step, you’ll get a blank result when calling an endpoint that return an array of data. Further testing using SoapUI will reveal some error like this:

Fixing is done, now we’ll test it.
For simplicity reason, we’ll put our client inside our Welcome controller. Here’s the code:

As you can see, the code is quite simple, $res1 will contain output from “getCdInfo” endpoint and$res2 will contain an array of CDs as a result from calling “getCds”.

Here’s the complete source code of our controller, in case you missed something:

## Problem:

You want to export your QGIS project into high resolution image. QGIS desktop “Project” –> “Save as Image” only save/export the project into a low resolution image (i.e. your desktop resolution).

## Solution:

### 1. Finish your project in QGIS

Finish your GIS project in QGIS Desktop, choose which layers to be shown, what style should it use, etc.

### 2. Choose your extent that will be exported into image

For myself, I choose the full-extent, but you may choose the extent as you wish. You my use “Vector” –> “Coordinate Capture” to help copying the coordinates. You will need to write down the coordinates for [xMin, yMin] (top-left coordinate) and for [xMax, yMax] (bottom-right coordinate). Save and close your QGIS project.

### 3. Execute the export command via command line of QGIS

Open your command prompt/console (preferably as Administrator/root). Go to your QGIS binary folder, where you install QGIS +”bin” folder, for example C:\Program Files\QGIS Brighton\bin. Use this command template:

For example:

That command will open QGIS Desktop for a moment then close itself. The command will produce padangsari.png in c:\users\achmadz\documents\. Open the image, and you’ll see the image in high resolution (5000×5000 pixels).

## Windows Installer Cleaner

Some background:

My SSD drive is almost full, after checking with TreeSize Free, it seems a lot of space is taken by files inside c:\windows\installer\. Searching around, I conclude that some of files is safe to be deleted from that particular place. There is a VB script in http://blogs.msdn.com/b/heaths/archive/2007/01/31/how-to-safely-delete-orphaned-patches.aspx that detect which files that shouldn’t be deleted from c:\windows\installer.

I also know an application named WiCleanup from KZTechs that detect and delete the “safe” files but after I tried it, the confirmation of deletion for files one-by-one makes me uncomfortable. So, I decide, why not programming the application by myself? And this application is born!

Implementation:

I programmed the application in VB .NET language using the free Microsoft Visual Studio 2013 Community Edition. Without further a do, you can download the application here:

(Of course you need .NET framework 4.5 installed if you want to run this application)
[button link=”http://www.ahowto.net/wp-content/uploads/2015/03/wic_winform.zip”]Windows Installer Cleaner Full Source Code[/button]

How to use:

It’s quite straight forward. There are three buttons there, you just need to click on them sequentially.

1. Click “Get Kept List” to see which files that you should keep on c:\windows\installer
2. Click “Get Delete List” to get the files that should be safe to be deleted and their size.
3. Click “Delete Files” to delete the detected files.

What I learn from building this application:

• how to create .NET application that need Administrator privilege (UAC things) when executed
• how to use COM object in .NET application
• how to use/import .dll from MS Windows in .NET
• some file operation in .NET (FileInfo, deleting files, file’s attribute)

Windows Installer Cleaner Screenshot in Windows 7 64-bit

The application is already tested on Windows 8.1 64-bit and Windows 7 SP1 64-bit. Both systems is running fine until now. 😀

## Play DASH video and DASH audio at the same time using VLC

DASH video and DASH audio formats option in vrank.org

Why? Well, the simple answer is: google/youtube separate the video into two stream: video and audio. So, when you are streaming a youtube video (using browser) in high quality format (720p and up), you actually download/stream from two different files.

Now, how can you play these two files (DASH video and DASH audio) at the same time? We will use VLC to do this!

• Let’s assume you already downloaded the two files (DASH audio and video)
• Open VLC
• Access Menu: Media –> Open Multiple Files…

VLC: Media –> Open Multiple Files…

• A new empty “Open Media” window will be opened, click on that “Add” button then browse and select your first file (could be DASH video or DASH audio file, not in particular order)

VLC: Open Media window

• Check/click/activate “Play another media synchronously …” then click on “Browse…” button

VLC: play other media synchronously

• A new empty “Open Media” window will be opened. Click “Add“, browse to your second files (either DASH audio or DASH video depended on your first opened file). Then click “Select” button (the button will become active/clickable after you choose your second file), this second “Open Media” window will be automatically closed.

VLS: a new empty “Open Media” window

• Now, you’ll have the two files chosen and listed on the first “Open Media” window. You may click “Play” button.

VLC: two files is selected

VLC will play those two files synchronously, you may check it via VLC menu: Tools –> Codec Information, there will be two stream played together.

VLC playing DASH video and DASH audio at the same time