Skip to content →

Tukang Kod Posts

Installing Nginx on CentOS

Step 6, 7 & 8 are entirely optional
1) sudo yum install pcre-devel zlib-devel openssl-devel
2) mkdir ~/sources
3) cd ~/sources
4) wget http://nginx.org/download/nginx-0.9.5.tar.gz
5) tar -zxvf nginx-0.9.5.tar.gz
6) mv nginx-0.9.5.tar.gz nginx
7) cd nginx
8) [if gcc not available] yum install gcc
9) ./configure –sbin-path=/sbin/nginx –conf-path=/usr/local/nginx/nginx.conf –pid-path=/usr/local/nginx/nginx.pid –with-http_ssl_module –with-md5=auto/lib/sha1
10) make
11) make install
12) cd /usr/local/nginx/
13) vi nginx.conf
14) nginx
Leave a Comment

Real-time database replication (almost!)

  1. Been fortunate enough to join the first batch (i think!) of Oracle GoldenGate (OGG) in Malaysia.
  2. OGG is the real-time database replication app which enhance Oracle Data Integrator (ODI).
  3. I’ve seen the reason why database replication are important nowadays. One that I can relate is the emerging of cloud computing which need replication geographically.
  4. Replication used by Disaster Recovery (DR) not usually replicate real-time.
  5. OGG in my oppinion is not suite for DR eventho it can do the job well.
  6. It suite well for real-time ETL in Data Warehousing and it can be geographically available in almost real-time.
  7. The interesting idea that can be archive via OGG is something like, you can separate heterogeneous database for different function (like oracle for write and mysql for read) and make the data available realtime. This architecture help when lots of reading needed on the data.
  8. Replication can be bi-direction, heterogeneous and multi master multi slave.
Leave a Comment

CakePHP Cookbook updated!

After almost 3 year using the old design, the team decide make a major facelift to the cookbook. They even put local cache function. kudos!

Leave a Comment

PHP5.3 : goto

Pernah guna fungsi goto? last time aku guna mcm 4-5 tahun dlu. sebab dulu PHP memang takde.

/* function lock */ function lock() { $file = fopen("file.txt","r+"); retry: if(flock($file,LOCK_EX)) { fwrite($file, "Success!"); fclose($file); return 0; } else goto retry; }

loop dalam function. nice?

Leave a Comment

CakePHP: Ternary condition

Kalau selalu guna if and else, langkah seterusnya mesti tahu ternary condition. ade alternative lain nak guna dalam CakePHP, contoh:

/* ife in cakePHP */ ife($condition, $true, $false)

jadi, kalau statement ternary tu cam ni:

/* ternary condition */ echo ($x)?'x = true':'x = false';

ble ubah jadi macma ni. mudah sket

/* replace ternary with ife in cakePHP */ echo ife($x, 'x = true', 'x = false');

urm.. dapat?

Leave a Comment

CakePHP: Kenapa layout masih tak tukar?

Kalau malas asik nak declare layout di cakephp, aku akan guna code macam ni.

/* before Render */ function beforeRender() { parent::beforeRender(); $this->layout = 'plugin'; .... }

lepas tu aku nak tukar stail layout, misalnya nak guna layout “ajax”. jadi aku declare macam ni..

/* children */ function children($id = null) { .... $this->layout = 'ajax'; }

tapi tak jadi!? kenape? perasan function beforeRender tu?

/* before filter */
function beforeFilter()
{
parent::beforeFilter();
….
$this->layout = ‘plugin’;
}

baru jadi! sebab beforeRender akan override balik variable sebelum render! sebab tu tak jadi.

One Comment

Html helper, link untuk plugin

Aku ada masalah nak buat link dari plugin page ke page biasa.

mula² jumpa cara macam ni..

$html->link(__(‘Home’, true), array(‘root’ => false, ‘plugin’ => false, ‘controller’ => ‘users’, ‘action’ => ‘home’), array(‘class’ => ‘menu’));

tapi still tak menjadi.. aku check cake version betul.. 1.2.5

jadi.. setelah mencari² cara macam mana nak reroute balik (kejalan yang benar) siap bukak source asal. rupa² nyer kena guna null. jadi seperti ni.

$html->link(__(‘Home’, true), array(‘root’ => false, ‘plugin’ => null, ‘controller’ => ‘users’, ‘action’ => ‘home’), array(‘class’ => ‘menu’));

kenapa false tak ok? pelik tapi benar

Leave a Comment

Inno.vasi

Kenapa aku pilih Drupal, padahal joomla lagi best. “Did you know that whitehouse.gov using Drupal?” fakta ni membuatkan orang mengangkat kening. Kebanyakkan masa aku hanya diluted dengan teori syok sendiri. Tapi sapa tau yang twitter dan facebook adalah next big thing, 2-3 tahun dahulu?

Continue reading Inno.vasi

Leave a Comment