Monthly Archives: June 2012

Basic Matrix operation in Lazarus/FreePascal

Well.. This is my first post about FreePascal (FPC)/Lazarus. I’ve been asked to create a simulation for artificial neural-network using backpropagation without using Matlab. So, I decided to use FreePascal/Lazarus to create it. Why? Because it’s challenging.. 😀

First problem that I need to overcome is how to mimic matrix arithmetic in FreePascal just like in Matlab. So, after some searching, I found satisfactory library called DynMatrix.

Download file from here:

Extract two files inside the archive, you’ll need only: dynmatrixutils.pas and dynmatrix.pas.

Use these two files in your project/form, example:

Now, for the example usage:
Declare a matrix variables:

Init a matrix into all zeros with 4 rows and 3 cols:

Setting a value for an element in matrix:

Getting the value of an element:

Matrix addition, subtraction, multiplication and matrix power:

Matrix transpose, inverse and convolution

Converting string to matrix:

Creating “eye” matrix:

Does this library also works on Delphi? Although I have Delphi, I haven’t tried it. So, no idea, but I’ve been looking at the source code and it seems it is OK to use it on Delphi Pascal. The dependecies is only on SysUtils, math and Classes

Free and OpenSource tabbed FileManager for Windows

There’s one that I like most: Double Commander. It’s totally free, no shareware or demoware, and open source and it’s created using Lazarus+FreePascal! Awesome!

double commander interface

double commander default two-windows interface

If you looking for an alternative to a shareware Total Commander, you are choosing the right one. Double Commander can also install+load plugin from Total Commander.

Although I said in the title it’s “for Windows” but Double Commander can run on Linux too. Since it’s created in FreePascal, it should be able to be compiled on Mac also. However the only available binary is only for Windows (32 and 64 bit) and Linux (also 32 and 64 bit).

If you don’t want to bloat your Windows registry, Double Commander also come in “portable” version. No need to install, just extract and you are good to run it.

Some notable features:

  • tabbed interface
double commander tabbed file manager

double window + tabbed file manager

  • built-in viewer (included hexviewer) and editor with syntax highlighting (although the recognized programming language is limited)
double commander built-in editor

built-in editor highlighting Visual Basic Code

  • extended search function, almost has all feature of Agent Ransack. You can easily search files that contain some words.
double commander extended search

full text search

  • built-in file comparator based on it’s content, multi-rename file, compress and decompress (ZIP, TAR.GZ, TGZ, LZMA, BZ2, RPM, CPIO, DEB, RAR), calculate (and verify) file hash, split and join files (no need hjsplit now 🙂 )
double commander additional functions

more built-in functions

If you want to download more recent (bleeding-edge/alpha) Double Commander for Windows 32bit and 64bit, you can head to:

Creating webservice server and client using NuSOAP

Brief description of NuSOAP:

NuSOAP is a rewrite of SOAPx4, provided by NuSphere and Dietrich Ayala. It is a set of PHP classes – no PHP extensions required – that allow developers to create and consume web services based on SOAP 1.1, WSDL 1.1 and HTTP 1.0/1.1.

Why using NuSOAP? PHP5 already has soapServer and soapClient implementation

  • it’s easy to implement and fast, no need to create WSDL document by yourself (this is my main reason why I choose NuSOAP)
  • compatibility, no special PHP extension need (I didn’t test it if still works on PHP4, but it does work flawlessly on PHP 5.0)

First, download NuSOAP from here:

The Server

We will create a SOAP server with two entry points (=function). One function take one parameter and output a string while the other one take two parameters and output a complex result (an array/struct). The codes with commentary:

Suppose that you save the codes in ws.php, you can see your neat webservice description by accessing the URL:
Try click on one of your webservice entry point! NuSOAP will show you a description about it, see screenshot:

webservice entry point description using NuSOAP

example of entry point description generated by NuSOAP

for WSDL XML document, you can see it at:

The client

The code is quite simple, all the code need is your webservice WSDL URL.

That’s it! Creating webservice server and client using NuSOAP is fast and simple. 🙂

Easily integrate/load PHPExcel into CodeIgniter Framework

PHPExcel is a set of PHP classes/library to read and write Excel files (.XLS/.XLSX). Based on CodeIgniter wiki page, integrating and using PHPExcel into CodeIgniter framework need some modification in PHPExcel source code. With the steps that I will show you, you will not need to edit any PHPExcel source code and the usage is very convenient just like you use on “plain-straight” PHP.

Pre-requisite: I tested this on CodeIgniter 2.1 and PHPExcel 1.7.7

Here we go:

  • download PHPExcel from (yup, they move from codeplex to github)
  • Extract the compressed archive (.zip or .tar.gz). Only extract the files inside Classes folder. Extract them to CodeIgniter’s application/third_party/ folder. Your application/third_party/ folder will look like this:
extract phpexcel into codeigniter

CI application folder’s structure

  • Create new PHP file inside CI’s application/libraries/ name it Excel.php. This is the source code (source [Bahasa Indonesia] [DEAD LINK!!]:

  • Your CI’s application/libraries/ folder will looke like this:
  • codeigniter's application/libraries stuctureThat’s it. Now you can use PHPExcel library in your CodeIgniter’s controller code.

Example usage (with commentary):

Have fun with CodeIgniter and PHPExcel! 🙂

TREQ A10C review

TREQ A10C is a low-end Android made-in-China tablet. I bought this tablet because although it’s low-end, it runs on Android ICS 4.0.3 (and my kids want Angry Birds Space  and Plants vs Zombie in this device 😛 ). The price is also affordable, IDR1,350,000.00 (about USD150) for the 16GB version.
Some basic system info (taken using Quadrant standard):

Treq A10C system information

TREQ A10C basic info

Graphic capability (also from Quadrant):

Treq A10C graphic component

TREQ A10C graphic capability

– cheap
– run Android ICS 4.0.3
– 1GHz single core processor (tweakable up to 1.5GHz) with 1GB RAM
– able to play MKV video (tested on 720p quality), subtitle is flawlessly shown.
– able to read external hard-disk (tested on my Toshiba 500GB), be aware though, Android will only read your first hard-disk partition
– already rooted
– Google Play/Market, Adobe Flash 11, HD games run smoothly
– HDMI output (cable is not included)
– 5 points multi-touch

– no GPS
– no compass
– no built-in modem
– no bluetooth
– no camera (well, there is a front VGA camera, it sucks)

Although this tablet hasn’t any internal modem (WiFi only), it does support some USB modem (GSM and CDMA):

treq a10c supported modem

Supported USB Modem by Treq A10C