Friday, January 30, 2009

CakePHP : AfterFind()

Rather than hacking the view to check if the number in my Inbox or Outbox table tally with my Contacts number, I use the afterModel() hack.

The Inbox Model


class Inbox extends AppModel {
var $name = 'Inbox';
var $useTable = 'inbox';
var $order = 'Inbox.id DESC';

function afterFind($results) {

// load Contact model here
App::import('Model','Contact');
$this->Contact = new Contact();

// For any results returned from the 'Inbox' model, take 'number' and check with Contact model
foreach ($results as $key => $val) {
if(!empty( $val['Inbox']['number'] )) {
if ( $contact_id = $this->Contact->findByMobileNumber($val['Inbox']['number'],array('id','name')) ){
$results[$key]['Inbox']['contact_id'] = $contact_id['Contact']['id'];
$results[$key]['Inbox']['contact_name'] = $contact_id['Contact']['name'];
}
}
}
return $results;
}

}


Try the output in view


Array
(
[Inbox] => Array
(
[id] => 266
[number] => +60146412911
[smsdate] => 2009-01-30 15:02:06
[insertdate] => 2009-01-30 15:02:25
[text] => test1243
[phone] =>
[processed] => 0
[read] => 1
[contact_id] => 14
[contact_name] => Bazet
)


Clean hack

)

Thursday, January 29, 2009

CakeSMS : 2 Way SMS

I just updated CakeSMS application. Adding validation to Outbox model so I can limit the text to 160 characters and only numeric format accepted in number field.

Then my phone rang, somebody from the govt interested with the product and asking about 2 WAY sms support.

For example

sending 'HELP' will list out all the command

sending ' get staff 3713' will list staff 3713 informations

Well, how do I do that ?

First I need to write a listener in CakePHP that run every seconds. the listener will read all the incoming SMS and will process the text, if the matching text found, it will trigger the command for that text.

Keep It Simple

How do I run PHP code forever then ?


while (1 == true) {
// logic is here
} ?>

Monday, January 26, 2009

CakeSMS Development


Running smsd in debug mode. You can clearly see whats happening.


This is group SMS interface. Just a simple one. Just choose the Contact Group, type the message, and all the SMS will be put on qeueu on Outbox table. SMS sending speed depends on how many modem attached to the system

Sunday, January 25, 2009

CakeSMS

Screw Ruby On Rails for a while, back to CakePHP. I've written a simple guide in PDF on how to deploy your own SMS server using normal hand phone and Linux via VMWARE. The PDF cane be downloaded at here, http://cakesms.blogspot.com

At the end of the session, you'll get a working web interface for managing incoming and outgoing SMS.

Now, I'm extending the functions to include :
1. Group SEND ( send SMS to all contacts under specified group )
2. Contact Group Management
3. Contacts Management
4. User Authentication
5. SMS log for incoming and outgoing message

Ok folks, that all for now. Going to finish the module in an hour or so

Thursday, January 22, 2009

FFMpeg to convert 3GP to FLV

Did you know, default FFMPEG binary can't convert 3GP to FLV ? You will need to compile back again.

I'm using Linux Centos 5.1 ( upgraded overnight using yum -y )

Step 1: Install Subversion and Checkinstall thru YUM
yum install subversion
yum install checkinstall
yum install git

Step 2: Create SRC directory, and Download the sourcecode
mkdir /root/src/
cd /root/src/
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
git clone git://git.videolan.org/x264.git
wget http://ftp.penguin.cz/pub/users/utx/amr/amrnb-7.0.0.2.tar.bz2
wget http://ftp.penguin.cz/pub/users/utx/amr/amrwb-7.0.0.3.tar.bz2
wget http://www.tortall.net/projects/yasm/releases/yasm-0.7.2.tar.gz

Step 3 : Untar
tar -xjvf amrnb-7.0.0.2.tar.bz2
tar -xjvf amrwb-7.0.0.3.tar.bz2
tar -xzvf yasm-0.7.2.tar.gz


Step 4 : Compile
$ cd yasm-0.7.2
$ ./configure
$ make
$ sudo checkinstall
$ cd ..
Libamr is the audio encoder/decoder for 3gp format
$ cd amrnb-7.0.0.2
$ ./configure –prefix=/usr
$ make
$ sudo make install
$ cd ..

$ cd amrwb-7.0.0.3
$ ./configure –prefix=/usr
$ make
$ sudo make install
$ cd ..

From Wikipedia: x264 is a free software library for encoding H.264/MPEG-4 AVC video streams
$ cd x264
$ ./configure –prefix=/usr –enable-shared
$ make
$ sudo checkinstall –pkgname=x264 –pkgversion “1:0.svn`date +%Y%m%d`-0.0ubuntu1″
$ sudo ldconfig
$ cd ..

$ cd ffmpeg
$ ./configure –enable-gpl –enable-swscale –enable-pthreads –enable-libvorbis –enable-libtheora –enable-libvorbis –enable-libgsm –enable-libdc1394 –disable-debug –enable-shared –enable-libmp3lame –enable-libfaad –enable-libfaac –disable-vhook –enable-libxvid –enable-libx264 –enable-postproc –enable-libamr-nb –enable-libamr-wb –enable-avfilter –enable-nonfree –prefix=/usr
$ make
$ sudo checkinstall or make install ( either one )

Social Networking @Jobber.MY

The social networking development engine is quite near to finish. It is one man job and I'm using Alan Bradburne's Practical Rails Social Networking Sites as guidance.

Well the book is good if you have basic Ruby knowledge. But I want to add Video engine. User can upload video in various format and rendered in FLV format.

I'm using Centos 5.1 VPS, and I need to install FFMPEG,

1. I use this guide to install FFMPEG ( turn off gpgcheck = 0 )
http://www.tuxmachines.org/node/17063

2. Then I ran yum install ffmpeg and yum install ffmpeg-devel

3. Run ffmpeg -v to check the version
[root@vmap1 social_networking]# ffmpeg -v
FFmpeg version SVN-rUNKNOWN, Copyright (c) 2000-2007 Fabrice Bellard, et al.
configuration: --prefix=/usr --libdir=/usr/lib --mandir=/usr/share/man --incdir=/usr/include/ffmpeg --enable-libmp3lame --enable-libogg --enable-libvorbis --enable-libogg --enable-libtheora --enable-libfaad --enable-libfaac --enable-libgsm --enable-xvid --enable-x264 --enable-liba52 --enable-liba52bin --enable-pp --enable-shared --enable-pthreads --enable-gpl --disable-strip
libavutil version: 49.4.0
libavcodec version: 51.40.4
libavformat version: 51.12.1
built on Jun 4 2007 11:02:12, gcc: 4.1.1 20070105 (Red Hat 4.1.1-52)
ffmpeg: missing argument for option '-v'


4. Cool. Now to install Background Worker for video conversion in Ruby On Rails
http://backgroundrb.rubyforge.org/

5. More reading @
http://kpumuk.info/ruby-on-rails/encoding-media-files-in-ruby-using-ffmpeg-mencoder-with-progress-tracking/

http://jimneath.org/2008/06/03/converting-videos-with-rails-converting-the-video/

Wednesday, January 21, 2009

200,000 workers to be retrenched in Malaysia

The economy slowdown not hitting Malaysia pretty bad. According to official press release by Human Resource Department in Malaysia, almost 200,000 workers will lost their jobs. Most of then came from manufacturing sectors.

So how to prepare yourself as a web programmer or web designer ?

For Programmers
  • 1. Equip yourself with latest development tool
  • 2. Intstead of know 1 programming language, extends to many such as PHP,Ruby,Python
  • 3. Try to minimize development cycle, this can be achieved if you're using RAD Frameworks like CakePHP, Code Igniter, Symfony or Ruby On Rails.
  • 4. Learn to write Ajax functions using Framework such as Jquery,MooTool and ScriptAculosU

PHP Programmers in Malaysia

PHP Programmers are the most demanded jobs at Jobber.my. Well at least in Malaysia, PHP Programmy are needed virtually anywhere. So how to be a PHP Programmer ?

Me myself have coding in PHP for since year 2000. My teacher is Google. Yeah, I'm self taught PHP Programmer and most of the PHP Programmers out there is same like.

So how to start ? If you have some basic programming like C and Java it will help a lot since coding in PHP is not much different in Java or C. But if you don't have any programming background, dont't worry. As long you're willing to spend time learning programming, in 1 year you can be a PHP programmer too.

Honestly, you need to spend some money for books and training. Just head up to any bookstore and look for Beginning PHP & MySQL from APress

Learn on how to program by yourself, not to copy others code and claim yourself as PHP Programmer.

Jobber.MY , Hub for ICT Jobs in Malaysia

Hosted with my friend webhosting, Zenpipe.com, Jobber.my was a successful hit. After 2 days of soft launch, almost 1000 unique users view the job board. Thanks for free website tracking, Google Analytics

The job board itself, is using free open source software, Jobber Base

Most of the job sites in Malaysia, are not targetting niche market like ICT, but Jobber.my does.

So if your company or just need a freelancer, you guys can post the job for free at Jobber.my