Tuesday, January 11, 2011

PHPExcel

PHPExcel make a nice looking table header
Actually is not really nice looking. Just a proper presentation...
There is too many code and I got no time to upload...

Sources from here
http://phpexcel.codeplex.com/Thread/View.aspx?ThreadId=32427

$headerStart = 22; //Start row

foreach( array( 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'M', 'N', 'O', 'Q', 'R', 'S', 'T') as $alphabet){
$objPHPExcel->getActiveSheet()->getStyle($alphabet.$headerStart)->getAlignment()->setWrapText(true);
$objPHPExcel->getActiveSheet()->mergeCells( $alphabet.$headerStart.":".$alphabet.($headerStart+1));
$objPHPExcel->getActiveSheet()->getStyle($alphabet.$headerStart)->getAlignment()->setVertical( PHPExcel_Style_Alignment::VERTICAL_CENTER);
}

Saturday, January 8, 2011

using permission?

You want to use anything inside my blog post? (such as code, tutorial etc)

Here is the permission upon each categories

Read here first
1st of all, most of my post has their own reference and I post back the link where I found it. Then I copy the same thing for myself use.
Thus, if I put the link you can check if the link stated about permission to use. I think most of the time the link will be on others blog or forum so I myself not even really sure about the permission...

Coding
This is a code that I made by myself. It is FREE and also 'AS IS'
Means you can use it for anything you want and anything happen is your responsibility
No need to credit me

Arts
Something that I draw and post it here. This is my artwork and I value it. You can use it but not for commercial
Need to credit me

Picture
Right now (so far) is my own sources of picture (I make my own screen shot or from camera). You can use this picture for anything and no need to credit me. If it is not my picture then ask the owner

Opinion / Tutorial (like comparing Ubuntu and Window)
It is just an opinion and tutorial. You can use it as long as credit to me

p/s: Credit to me means if you copy the post into somewhere and telling 'this is from this link' not compulsory to ask my permission to use it or telling 'original author is asipo'

Friday, January 7, 2011

windows or linux(ubuntu)?




In this post is discussing about which OS (operating system) you should use
When I said linux it focused on ubuntu but this might also apply to other Linux OS too

I do belive (im Malaysia) majority is using Windows. So lets start using my believe...

You 100% cannot use ubuntu when
- You are a gamer. Cause most of game was on Windows

If you still insist using ubuntu while you are a gamer
- Yes you can try, install ubuntu inside windows (they called it wubi i think)

You 50% (might can) use ubuntu when
- Using it as home user; surfing, typing and chatting
- Another 50% goes to your 'resistance to change'

Here is my resistance to change from windows to ubuntu
1. Im used to Microsoft office, using open office is weird. This is first time, after 2 month of using it I can say "I like open office a bit more than ms office"

2. Surfing - There is no google chrome. Well can actually download it. Just "Installation in Windows is different in Linux"

3. Chatting - Ubuntu dont have Yahoo Messanger (not sure about MSN). But luckly they have empath or pidgin. You can still chat but less feature compared to YM. The best part using empath is "No advertisement + Faster!"

4. Used software - Let say you used to certain program like 'Yahoo messanger'. This software does not exist in Ubuntu, so either you find alternative or leave it

Repeat, 'you used to windows until you feel like dont want to use linux' is common and this is the most reason of 'dont want to change' aka 'resistance to change'. I myself happen to have this feel



What so good about Linux ? (focused on Ubuntu). Well, this is most likely my experience and opinion.

good thing #1
Better security. All you virus from windows will not work (No virus). Remember better doesn't means impenetrable. But it do better than windows in almost all of the case

How to apply this 'good thing #1' ?

1. If you have a 'home PC' and you kids or parent is using the PC. You PC have high % of getting virus or malware or what ever dangerous stuff. This is the solution and the reason I keep suggesting it to others

2. If you were student and keep getting virus from 'Lab' (this is typical way for Malaysians PC to get virus, usually pendrive is the transfer medium). This linux will solve the problem 100%

3. If you create 2 type of user. The lower user cannot access the other files. Err... this is linux security like folder owner and folder group permission stuff. I never care about this. but in case you have 'sensitive data' Linux can help it

4. You dont need to buy Kaspersky on install antivirus. yeay!


good thing #2
I admin installation in Linux is hard (you need to use command line in special software). but ubuntu make it easy, you have a feature like 'add remove program in windows' but it 10x advance

1. They have 'update manager' this is to install or update driver

2. They have 'add remove software'. It can remove and also ADD! ADD! ADD! ADD! ADD! free software. There is tons of free software outside

How to apply this 'good thing #2' ?

1. My parent like to play solitaire in Windows when free time. If you use ubuntu you can ADD! ADD! ADD! ADD! ADD! games for free and the game is better than windows. This only apply for small and simple game, as I said 'home typical user' (not gamer sejati!)

good thing #3
Faster, better, stronger, harder...
This most likely what I hate on Windows after using Ubuntu

Windows have a little but yet annoying problem when it come with thumbdrive/pendrive
- SLOW
- Cannot eject, something was in use

So if you use Ubuntu you can feel the smoothness in detecting pendrive, eject is easy and transfer file is also FAST!
The main point is 'Stable' I guess

So... thats it I know

Thanks
Myself

trying linux? try ubuntu!

I already test several linux based system and touch it on surface as 'normal user'
Normal means I use it for office, chatting and surfing

Not like awesome hacker or freaky nerd cause they are +10 level higher

So I have test
1. Ubuntu
2. Fedora
3. Redhat
4. SUSE Server Linux <-- not sure correctly spelled

Redhat and SUSE is because of my workplace, so I'm not suggesting you to use it for home. Not it leave either Ubuntu or Fedora

Straight to the point = use ubuntu

Reason?

Lets start with bias
1. I have use ubuntu longer than fedora, so maybe the 'feel' make me suggesting ubuntu

Another reason, semi bias or more like personal experience / opinion
1. Ubuntu have better interface
2. Easily install and update 'FREE BUT NOT ACTUALLY FREE' driver / software
3. Better ERROR display (this is a level newbie 60% - intermediate 40%)

Other than that is nu thin much except I like fedora default wallpaper
By chance, if fedora ambassador is reading this, please do not get angry :D

Ubuntu swap space

If you want to use ubuntu, there is 2 type of typical installation

1. Install in windows (called wubi i think)
2. Install in empty partition (means you format you partition or resize)

For 'I want to try' users. Just take no1 it seriously awesome and easy

For 'I can use ubuntu!' users. Option 2 is additional

Note that if you format window, they will reset the boot loader (not sure the real term) so you ubuntu will not displayed. (I still not reach a level on how to get solve this problem, but do believe it is 99% can be recover)

Installing 1st option require no skill, but 2nd option does require some knowledge

For anyone who didnt know about linux (like me) this might be helpful. Others this is newbie

Lets proceed with 'how to install using the 2nd option'

1. During installation you need to specify 'where you want to install the ubuntu'

They will show 3 option
1. Install side by side (I already forgot about this, but do use it once)
2. Install in whole (format 100% you hdd, all partition)
3. Install in specific

This post is about option 3

When you select option 3, you can choose which partition you want to format and install ubuntu on it

Remind that you need to make 2 partition. 1st is the real partition and the 2nd will be the 'temporary what? i forgot'

1st partition will be a dropdown writing 'ext4'
make 2nd partiton 2G space only! (this is the reason I write this post, cause my newbieness create 10G space yo). They type was 'swap space'

note that there is a debate on how many swap space you should allocate. This 2GB is my opinion after 30min of google

After setting up this 2 partitions just proceed like normal (cause installing ubuntu was easy)

Wednesday, January 5, 2011

CakePHP connect 2, many, multiple database

Tag
CakePHP connect with more than 1 database
CakePHP connect multiple database
CakePHP connect more database
CakePHP connect 2 database
CakePHP connect with 2 database. 1 is CakePHP structured and another 1 is not

The main source is from here
http://blog.4webby.com/posts/view/6/cakephp_models_using_multiple_db_connections

Repeat the same thing
class DATABASE_CONFIG {

var $default = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'your_host',
'login' => 'your_login_1',
'password' => 'your_password_1',
'database' => 'DB_1',
'prefix' => ''
);

var $general_syst = array(
'driver' => 'mysql',
'persistent' => false,
'host' => 'your_host',
'login' => 'your_login_2',
'password' => 'your_password_2',
'database' => 'DB_2',
'prefix' => ''
);
}
?>

class User extends AppModel {

var $name = 'User';
var $useDbConfig = 'general_syst';

//your code here
//....
}

class Post extends AppModel {

var $name = 'Post';
var $useDbConfig = 'default';

//your code here
//....
}

$this->Post->bla_bla_bla : data will be retrieved/inserted/updated from DB_1
$this->User->bla_bla_bla : data will be retrieved/inserted/updated from DB_2


Here is some additional
1. I can connect even without make it persistance.

pr($this->Student->useDbConfig);
$this->Student->useDbConfig = 'general_syst';
$ret = $this->Student->query("SELECT * FROM tbl_lecturer");


Note that tbl_lecturer is another non cakePHP database. It used MySQL database and query does take the data nicely

If you want to check the database connection. Refer here http://asipi.blogspot.com/2011/09/cakephp-check-database-configuration.html

Sunday, January 2, 2011

Smarty array

Case: Want to make a loop but need to check "the value is an array" or "the value has a value". I'm using smarty code template (.tpl file). Keep having this problem so I job this down to myself

Reference
http://www.smarty.net/forums/viewtopic.php?t=9891

Rewrite it back
use count() -> http://uk.php.net/manual/function.count.php
or isset() -> http://uk.php.net/manual/en/function.isset.php
or empty() -> http://uk.php.net/manual/en/function.empty.php

Maybe later want to write how to create a loop from the array data... but quite lazy rite now