Facebook Connect

Facebook connect ကိုတော့ လူတိုင်း သိကြမှာပါ။ facebook connect က ကိုယ့် site ကို user တွေ register လုပ်စရာမလိုပဲ user information ရနိုင်တဲ့ နည်းပါ။ register လုပ်တယ်ဆိုတာကလည်း user information နဲ့ password အတွက် register လုပ်ရတာပဲ။ လူတော်တော်များများက register လုပ်ဖို့ ပျင်းကြပါတယ်။ ကျွန်တော် အပါအဝင်ပေါ့။ အဲလို အခါတွေမှာ facebook connect လေးနဲ့ site ကို login ဝင်လို့ရရင် အရမ်းကို အဆင်ပြေပါတယ်။ ထပ်ပြီး register လုပ်စရာ မလိုပဲ site ကို အသုံးပြုလို့ရတယ်။ အခုအချိန်မှာ site တော်တော်များများက facebook connect ကို အသုံးပြုနေကြပြီ။ ကျွန်တော်လည်း ornagai မှာ ထည့်မှာပါ။
Continue reading

PHP Gtalk Bot လုပ်မလား

လွယ်ချက်ကတော့ ကမ်းကုန်ပဲ။ http://www.imified.com/ ကို register လုပ်။ bot create လုပ်။ ပြီးရင် PHP code တစ်ခုရေး။

<?php
echo $_REQUEST['msg'];
?>

အဲဒါဆိုရင် user ကရိုက်လိုက်တဲ့ဟာကို ရမယ်။ အဲဒါကို တနေရာမှာ host ထိုင်။ bot ရဲ့ address ကို အဲဒါပေးလိုက်။ ပြီးရင် gmail username နဲ့ password ထည့်။ active လုပ်။ ပြီးပြီ။ စိတ်ပျက်ဖို့ကောင်းလောက်အောင် လွယ်တာ။

External Link :

http://www.labnol.org/internet/tutorial-create-bot-for-gtalk-yahoo-messenger/4354/

Jumping to PHP framework

အရင်တုန်းကတော့ PHP Framework အကြောင်းပြောခဲ့ဘူးတယ်။ MVC အကြောင်းလည်း ပြောခဲ့ဘူးတယ်။ အခု ကျွန်တော်တို့တွေ framework ကိုပြောင်းသုံးတော့မယ်။ ဘာပိုကောင်းတာတွေလဲဆိုတာကို သိပြီ။ ကျွန်တော်တို့framework ကိုပြောင်းသုံးသင့်မသင့် စဉ်းစားရအောင်။

ဘယ်သူတွေပြောင်းသင့်လဲ။

ပြောင်းသင့်တာကတော့ Professional PHP Web Developer တွေပဲဗျ။ ဟင် professional web developer တွေပဲလား။ basic သမားတွေက ဘာလို့ ပြောင်းလို့မရမှာလဲ။ အဲလို မေးလာရင်တော့ ပြောင်းချင်ရင် ရပါတယ်ဗျာ။ အဲလိုပြောင်းလိုက်တဲ့အခါမှာ အခြေခံပိုင်နိုင်ခြင်း မရှိသေးပဲ Framework ကိုပြောင်းလိုက်တဲ့အတွက် နောက်ပိုင်း framework ကို သဘောကျပြီး ဆက်သုံးဖြစ်လိမ့်မယ်။ အဲဒီအခါ PHP ရဲ့ code အချို့ကို မေ့ကုန်လိမ့်မယ်။ နောက်ထပ် framework ကို ပြောင်းရင် အခက်အခဲတွေ ရှိလာနိုင်တယ်။ တနည်းပြောရရင်ဗျာ.. foundation ခိုင်ဖို့လိုတယ်။ foundation မခိုင်ပဲနဲ့ အဆင့်ကျော်တက်ရင် မြန်တာပဲရှိမယ်။ တြိဂံ ပြောင်းပြန် ကြီးဖြစ်သွားလိမ့်မယ်။

Continue reading

Python VS PHP

Source code For Zawgyi 2008 TO Zawgyi 2009

Python

import sys,re
ENC='utf8'
def zawgyi2new(d):
	m=open("zawgyi2new_replace.ini").read().strip().decode('utf8').replace("-",'').replace(' ','').split("\n")
	for x in m:
		x=x.split("\t")
		if x[0]in d:
			d=d.replace(x[0],x[1])
	return d
if __name__=='__main__':
	infile=sys.argv[1]
	d=open(infile).read().decode(ENC)
	d=zawgyi2new(d)
	outfile=infile[:infile.rfind(".")]+"_out.txt"
	open(outfile,"wb").write(d.encode(ENC))

PHP

$time_start = microtime(true);
// get contents of a file into a string
$filename = $argv[1];
$handle = fopen($filename, "r");
$d= fread($handle, filesize($filename));
fclose($handle);
$myFile = "zawgyi2new.ini";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);

$theData=str_replace("-","",$theData);
$m=split("\n",$theData);
foreach ($m as $x)
{
	$k=split("	",$x);
	if(strripos($d,$k[0])!=false) 	$d=str_replace($k[0],$k[1],$d);
}
$fp = fopen("convert_".$argv[1], 'w');
fwrite($fp, $d);
fclose($fp);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Total ".$time." seconds";

Python က 1 second နဲ့ 3 MB ရှိတဲ့ file ကိုပြီးတယ်။ PHP ကတော့ 29 seconds လောက်ကြာတယ်။ python က ၁၅ လိုင်း။ php က ၂၃ လိုင်း။ အချိန်တွက်တာ မပါရင်တော့ လိုင်း ၁၉ ပေါ့။ ဒီထက်တိုအောင် ထပ်ရေးမယ်ဆိုရင်တော့ ၁၇ လိုင်းလောက်နဲ့ ပြီးတယ်။ ရှင်းအောင် ရေးထားလို့ပါ။ PHP နဲ့ ၁၅ လိုင်းလောက်နဲ့ရအောင် ရေးလို့ရတယ်။ ဒါပေမယ့် ဖတ်ရတာ ရှုပ်သွားမှာဆိုးလို့။

Python is very faster than PHP

Same Algorithm, Same Logic, နဲ့ရေးထားပြီး 30 MB text file ကို PHP နဲ့ပြောင်းတာ second 29 ကြာပေမယ့် python နဲ့ကတော့ 1 seconds ပဲကြာတယ်။

searching တွေအတွက် crawling တွေအတွက် Giga Bytes လောက်ရှိတဲ့ Filesize တွေ အတွက် PHP ထက် Python က ပိုသင့်တောှတယ်။ Python ကို လေ့လာဖို့တော့ လိုလာပြီ ?????

Short Note Of PHP — 2

Integer

ပေါင်းနှုတ်မြှောက်စား ကိစ္စတွေအတွက် အသုံးပြုတယ်။

Strings

စာတွေ text တွေအတွက် အသုံးပြုတယ်။

$str=”Hello World”;

Booleans

True or Flase condition တွေအတွက် အသုံးပြုတယ်။

Compound Data Types

အခြား ထပ်မံပါဝင်တဲ့ data types တွေကတော့

Arrays – variable တစ်ခုထက် ပိုတာတွေကို သိမ်းတယ်။ နောက်ပိုင်း Arrary အပိုင်းမှာ ပါမှာပါ။

Objects – data ကော code ကော နှစ်ခု လုံးပါဝင်ပါတယ်။

Other Data Types

NULL – ဘာမှ မရှိတဲ့ value။ No value ပေါ့။

resource – PHP မှာ သီးသန့်အသုံးပြုတာ။ external resources တွေကို ညွှန်ပြပေးတယ်။

Converting Between Data Types

float နဲ့တွက်ပြီး int ပြန်ထုတ်ချင်တဲ့အခါမှာ

$x =10.88;

echo (int) $x; //outputs 10

Variable

Variable ဆိုတာ temporary storage containers တွေပါ။ Variable name တွေကို a-z,A-Z စပြီးပေးလို့ရပြီး နောက်ပိုင်းမှာ number တွေ လိုက်လို့ရတယ်။ underscore( _ ) လည်းလိုက်လို့ရတယ်။ number တွေနဲ့စပြီးတော့ ပေးလို့မရပါ။ special character တွေပေးလို့မရပါ။ _ နဲ့စပြီးပေးလို့မရဘူး။

$name=”valid”; //Valid Name

$_name=”invalid”; //Invalid Name

$1name=”invalid”; //Invalid Name,start with a number

Variable Variables

$name=’foo’;

$$name=’bar’;

$echo $foo;

//Display ‘bar’

$$ သုံးလိုက်တဲ့အတွက် $name ရဲ့ foo က variable ဖြစ်သွားတယ်။

$name=’123′; // 123 is your variable name, this would normally be invalid.

$$name=’456′; // Assign, you assign a value

echo ${’123′};

//Finally, using curly braces you can output 456

variable ကလည်း function ဖြစ်နိုင်တယ်။

function myFunc()

{

echo “myFunc”;

}

$f=’myFunc’;

$f(); //wil call myFunc();

Determining If a Variable Exists

Variable ရှိမရှိ စစ်မယ်ဆိုရင် isset ဆိုတာနဲ့ စစ်လို့ရတယ်။ boolean return ပြန်တယ်။ ရှိရင်1 လို့ ပြန်တယ်။

echo isset($x);

ZawgyiNorSB

zawgyi 2008 ကို 2009 ပြောင်းပေးတယ်။ normalization လုပ်ပေးတယ်။ syllable breaking လုပ်ပေးတယ်။ 2008 -> 2009 နဲ့ normalization က ကိုစိုးမင်းရဲ့ python ကိုပဲ ဖတ်ပြီး PHP နဲ့ရေးထားတာ။ syllable breaking ကတော့ python code ကို သေချာနားမလည်လို့ အရင်က ဟာပဲ ပြန်သုံးထားတယ်။

http://code.google.com/p/zgnorsb/