Sunday, January 30, 2011

Prevent mail from spam or junk by encryption from crawler

If you write a blog and put your email on it. There is a chance for you to get Spam/Junk mail
This can be cause of many reason but I'm focus on crawler method

How this spam works?
Basically this is the procedure
1. They find your email
2. They write email to you

Spam usually include 1000 email or more and of course it is done by using a bot (a system) and not just people manually type in

To find your email
They using web-crawler, spam-crawler or anything-crawler. These crawler will browse slowly through the internet (from blog to blog, website to website until forever). If your blog put an hyperlink of your friend blog (blogroll they called) these crawler will go into it

Thus in, programming these crawler detect 2 things

1st detection
Detect "http://" text. If they found and word, URL or string match. They will retrieve the link and put in on the "Next going to be crawl list"

2nd detection
Since they want to spam to your mail, they simply find any string or word with "@" symbol. Thus your email will be captured in these process

Write email to you (spam)
These is a process of producing mass email and of course they use the list they got from the first step and use a bot (system) to mass mail it


Prevention

There is 2 type of prevention
1. Email filter (thats why you have spam/junk mail categories)
2. Prevent your email from being on the spammer list

1st prevention - Filter your mailbox
This is already common and build in feature for almost all email system like gmail and others. So no need discussing much

2nd prevention - Prevent from listed
This is what I want to discussed about
Usually people will make their email not in easy format or encryption.

Using different email format like (let say your email is ajskdhqjeakjbdia@gmail.com)

Email: ajskdhqjeakjbdia (@gmail)

Email: ajskdhqjeakjbdia at gmail dot com

Or they use encryption like these

ajskdhqjeakjbdia@gmail.com
(It looks normal but it is actually encrpted)

So these encryption can be easily google. But I'm suggesting you the simplest one which taken from these website http://www.web-designz.com/tools/email_encoder.shtml
Note: The simplest method might also means it is easily detectable by the crawler

If you are a programmer and wandering how did the website do the answer is they are using convertToUnicode(...) function

If you view the page source. It wont show and "@" or your email at all because it is encrypted and of course the crawler is a system, they read the page source and not reading like you did (using web browser)

-End-

GIMP save for web image optimize reduce size

If you are using Windows and want to upload huge picture size into the internet (or blog) optimize it first using Adobe Photoshop 'save image as web' feature. It can reduce image size and make your image to load faster!

Story
Im using ubuntu and they dont give adobe photoshop crack for free :(
But I need adobe photoshop 'Save image as web' feature.
Ubuntu only provide me 'GIMP' but I found the same feature as a plug-in

Straight to the source. I copy from here http://www.techzilo.com/install-save-for-web-gimp-plugin-ubuntu/

What is 'Save image for web' ?
Save image for web is a technology to compress the image size so it can load faster in the internet

Weakness
Reduce the image quality. But this wont affect much (unless you have super vision)

Advantages
Image load faster

Conclusion
The advantages overcome the weakness make this a good thing to share!

Others
I was kinda lazy to write the thing back cause the source it self is already 100% fool proof

Saturday, January 29, 2011

Make a horizontal list



This is more like HTML & CSS tutorial to make ordered list to go vertical

This is order list (normal)
  • Hello
  • This is
  • Testing

This is order list (horizontal)
I actually copy the code from this guy http://leandrovieira.com/projects/jquery/lightbox/

<style type="text/css">
    /* jQuery lightBox plugin - Gallery style */
    #gallery {
        background-color: #444;
        padding: 10px;
        width: 520px;
    }
    #gallery ul { list-style: none; }
    #gallery ul li { display: inline; }
    #gallery ul img {
        border: 5px solid #3e3e3e;
        border-width: 5px 5px 20px;
    }
    #gallery ul a:hover img {
        border: 5px solid #fff;
        border-width: 5px 5px 20px;
        color: #fff;
    }
    #gallery ul a:hover { color: #fff; }
    </style>


<div id="gallery">
 <ul>
  <li>Hello</li>
  <li>This is</li>
  <li>Testing</li>
 </ul>
</div>


The result

Write blog post using TinyMCE

Google blog text editor has improved!.They have "Edit HTML" or "Compose" tab (like below)



Tuesday, January 25, 2011

HTML UTF encoding entities


I was doing some project require math symbol. The key was not exist in keyboard
The website that I use as reference is
http://www.fileformat.info/info/unicode/char/b1/index.htm
The link is a plus minus symbol (±). You can search fur further symbol at the top left

Or also here
http://www.danshort.com/HTMLentities/index.php?w=hertz

Sunday, January 23, 2011

CakePHP jquery autocomplete

Im using cakephp 1.2 and want to make autocomplete on them
Have googling for several hours (including tying it) and finally succeed

p/s: Im using try an error method. Im afraid that this 3rd try was success because of additional code I have put during try #1 and #2

1st I try to use this and succeess (except when want to autocomplete from database source)
Using original jquery http://jqueryui.com/demos/autocomplete/ which is version jquery-ui-1.8.8.custom.min.js and jquery-ui-1.8.8.custom.css

2nd was from this blog (this fail)
http://nuts-and-bolts-of-cakephp.com/2008/05/07/jquery-autocomplete-in-cakephp/
http://www.pengoworks.com/workshop/jquery/autocomplete.htm

3rd was from this website
http://www.cakephp.bee.pl/ajax/autoComplete

Thanks for all those programmer who make my life easier

After several investigation (I go crazy with these 2nd try for almost 2 days and turned out it cause of URL?)
I manage to enable the 2nd try. The reason of error is because I didnt put my system name
the website tutorial said "/products/autoComplete" but if your CakePHP 1.2 system name is 'accounting' means its going to become '/accounting/products/autoComplete'

What next? I want to make the view to be able to save more Account name. Thus is use a loop like this
input("Account.$aa.name"); ?>
input("Account.$aa.id"); ?>

Remember, the account name is just a name. At the controller what matters is the Account.$aa.id
Thus, after the autocomplete on the Account Name, the Account Id will be put the Id of the selective Account

To do this you require to modify function findValue(...) because this is where the event for 'Choosing which Account Name from the list of autocomplete'. And also a dummy input and one new function

New dummy input (on the view)
<input id="tempCount" value="" />

New dummy function (on the view at the javascript)
function tempCountert( theTempCountValue)
{
document.getElementById('tempCount').value = theTempCountValue;
}
Then you need to change you loop for the account name

From
input("Account.$aa.name"); ?>

To
input("Account.$aa.name", array( 'onchange'=>'tempCountert("Account'.$aa.'Id")')); ?>

Finally will be on the function findValue(li). Make sure to add this code
var updatedColumner = document.getElementById('tempCount').value;
document.getElementById(updatedColumner).value = sValue;



How my code works?
  1. You type in some value in the 'Account name' and the autocomplete list out the match
  2. When you click one of the match result. The dummy input (tempCount) will change the value to Account Name index. let say Account.0.name will print out 'Account0Id' in dummy input
  3. Function findValue(...) will be executed. And get the value in dummy input. Thus change the value

Thursday, January 20, 2011

Netbeans detect cakephp .ctp file

It is happen I use Netbeans as IDE and CakePHP as web framework
The problem is Netbeans only detect .php, .html and others but not .ctp file

.ctp file is a cakephp file which is similar to .php (dont know why these cakephp guys want to use different file name)


Fow Windows users

And to make the Netbeans to be able to detect it was originally from this blog http://www.davidtan.org/netbeans-enable-syntax-hightlighting-for-cakephp-ctp-view-files/comment-page-1/#comment-18469

I rewrite down the same thing
  1. From the Menu, go to Tools > Option (Then there will be a pop-up window named "Options")
  2. From the Options windows there is several Tabs, click on the "Files" tab
  3. Under the Files tab, there is a "File Extension:". Try to create a new file extension and name it "ctp"
  4. Then "Associated File Type (MIME)" for the ctp file extension, set it to "text/x-php5"
  5. Finally press "OK" button at the bottom


For Ubuntu users

I found the solution from here, pretty much the same but slightly in different place
http://forums.netbeans.org/post-60683.html&highlight=

Write back same things
tools > option > miscellaneous > Files tab

PHP generate document PDF, ODT, Excel (XLS)

Just to record down any PHP library that can help in generate document

PDF
FPDF = http://www.fpdf.org/

ODT
odtPHP = http://www.odtphp.com/

XLS (Excel)
PHPExcel = http://phpexcel.codeplex.com/

odtPHP is from Anaska. Who / what is Anaska?
Not sure for myself but I do belive they produce something really useful. Check out your WAMP it is from Anaska too :D

Recover delete data or partition using testdisk & photorec

Related name
  • Recover deleted data
  • Recover data in deleted partition


From the last post (http://asipi.blogspot.com/2011/01/merge-harddisk-partition.html), the software have made my friend harddisk partition to go 'missing'. This is how I recover the data in the 'missing' partition back
Straight to the point, use testdisk & photorec link is here http://www.cgsecurity.org/wiki/TestDisk


If you are bored and want to read the whole story, proceed...

What is recovery and what is backup?
Both of them relate with 'keeping your data safe'. Backup is prevent while recovery is cure

Thus,

Backup
Save important data before your harddisk become corrupt

Recover
Get back important data after harddisk become corrupt

Backup is better than recover because, recover not guarantee 100% success but you will never know 'when to do the backup?'

This post focused on recovery
Okay, there is 2 software that I would like to suggest in recovery

1st software, Recuva
This is recommended by my friend and when I see it (not try) I do feel like this software is good. Here is the link http://www.piriform.com/recuva




2nd software, testdisk & photorec
This is the software that I want to promote actually. Here is the listed advantages that I know

Good detecting
Several software cannot detect corrupted harddisk. But this software can!. So when recover my friend harddisk it let me select the corrupted harddisk, the partition to recover

Harddisk format supported
There is alot of harddisk type it can support, typical that I still can remember is NTFS, FAT, Solaris (what is this?) and bla bla bla...

How good this recover?
It recover is 100% good. This is because they scan the harddisk by memory allocation.
Means as long as there is any single bytes in the harddisk will be scan. The problem was it was too good until unwanted data is also recover.
Chance of getting corrupted file is also high (because it was too good, seriously!)

*It cost RM 300 - RM 500 to recover you harddsik (in business). And knowing this cost you RM 1 (your electricity bill and time wasted to read)

Weakness
The first weakness but still not a 'real weakness' for me. Which is this program is in a commandline.Since im a programmer (and used to it), I'm going to said their commandline interface is excellent

Second weakness is it recover all the data as possible. Means your deleted file 1000 years ago is also possible as a result it highly corrupted. This is what happen if you want to perfection in recover

Wednesday, January 12, 2011

jQuery navigation menu

Im not sure does anybody know about this. Think it will be easier to find in google
Below is the link for website that show example on jQuery navigation menu

36 Eye-Catching Jquery Navigation Menus
http://www.1stwebdesigner.com/resources/36-eye-catching-jquery-navigation-menus/

By the way, the website it self http://www.1stwebdesigner.com is totally awesome for me

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

Saturday, January 1, 2011

Merge harddisk partition

Okay, It was happen I use ubuntu and make 2 partition (1 the main partition and the other 1 is the swap space)
But then I want to use Window again and 'hey!, the partition is separated. How do I merge it?'

So I'm doing some google and here is the website that solve my problem http://www.extend-partition.com/
They have Home Edition which is FREE

THEN, MY (FRIEND) 2ND PARTITION IS MISSING!!!!!!!!!!!!!