The name is
Mike Myat Min Han aka 'mmhan'.

I am a developer, mostly do development on Javascript, PHP and CakePHP alongside some development work on C, C++, Obj-C, C# and AS. I also have a thing for Python.

I post here all sorts of crap that I find worthy of sharing: Quotes, Jokes and Notes.

You can check out my blog and follow me on twitter.


Posts tagged devnotes


Text

May 14, 2011
@ 12:41 am
Permalink

11 notes

CakePHP HABTM relation Data Format

The following is the format for $data that CakePHP expect on your Model->saveAll($data) call, using the example of Article and Tags.

array(
    'Article' => array(
        //Article data goes here as usual
    )
    'Tag' => array(
        'Tag' => array(
            1,
            2,
            3
        )
    )
);

Just thought I should note down in case I forget again, like I just did.


Text

May 12, 2011
@ 12:33 am
Permalink

return;

When a geek send you return; in the chat, get the fuck out of the conversation, and be quick about it.

You don’t want him throwing tantrums at you, or worst, a stack of formidable 1337 speak curses.


Text

May 11, 2011
@ 7:00 pm
Permalink

20 notes

How do you define a variable in MySql?

Here’s how:

SET @name = "Mike", @twitter = "@mmhan";

/** usage **/

SELECT * FROM `users` WHERE `name` = @name AND `twitter` = @twitter;


Text

May 10, 2011
@ 7:00 pm
Permalink

2 notes

Writing Secure PHP

I was reading this article called Writing Secure PHP, and found a little treasure in that article. 

It’s a hand-out for clients listing out a few basic security details. 

Just noting it down here in case I might need it in time.


Text

May 9, 2011
@ 11:01 pm
Permalink

1 note

Using PHP to upload to S3

So, my boredom continues on resulting in this:

Guess what, with this tutorial on nettuts, it’s pretty easy too!


Text

May 9, 2011
@ 9:34 pm
Permalink

Diving into S3

Outta boredom and curiosity, I followed a tutorial on nettuts and viola! The following image is served from Amazon S3!

Image served from S3

It is, however, such a shame that it took me this long to start dipping my toes in S3.


Text

May 6, 2011
@ 5:50 pm
Permalink

1 note

Creating a zip of modified or created files in GIT

So, how do you create a zip file of all the files that was changed to deploy?

Easy does it as answered by Jefromi:

git archive -o [PATH] [NewCommit] $(git diff --name-only [OldCommit] [NewCommit])

So it may goes like:

git archive -o ../latest.zip HEAD $(git diff --name-only 2f646b HEAD)

Text

May 6, 2011
@ 4:14 pm
Permalink

Facebook Graph API OAuthException

Ever encountered an OAuthException that has the following message?

The post's links must direct to the application's connect or canvas URL.

It is due to the settings from the screenshot below.

Just ensure Stream post URL security is disabled.


Text

Apr 27, 2011
@ 5:04 pm
Permalink

How to define a Class in Javascript

First of all, There is no such thing as a Class in Javascript. It’s all objects. Hence use functions and literals to simulate “Class”y development.

 
//Way 1: Function simulating class. 
function Phone(model){    
    this.model = model; 
} 
myPhone = new Phone("Android");  

//Way 2: literal as singleton 
var Phone = {
    model: 'Android' 
};  

//Way 3: Singleton into function 
var Phone  = new function(){     
    this.model = "Android" 
}

Read Stoyan Stefnov’s article for more.


Text

Jun 25, 2010
@ 1:41 pm
Permalink

iPhone Simulator

Springboard failed to launch with error -1

Ever had any of that error? Exit the simulator and restart it. It should work.