How to install Memcached on Windows machine

After some research I found that there is a Win32 binary version of memcached available here.

So go there and download win32 binary version to your computer. When downloaded, extract the file to folder memcahced on your C partition.

You should get only one file named memcached.exe. Now we need to install this as a service, as memCached is daemon and should be run only as service.

To install Memcached as a service, follow these steps (please change all forward slashes to backslashes):

  1. If you’re running Vista, you should set memcached.exe to Run as administrator
  2. Install the service using the command:
    1 c:/memcached/memcached.exe  -d install

    from the command prompt

  3. Start the server from the Services or by running one of the following commands:
    1 c:/memcached/memcached.exe -d  start

    or

    1 net start "memcached Server"

That is it, now your memcached server is installed and is listening to port 11211. There is one more thing left to do. By default, server is set to 64Mb memory limit, which is too small. To correct, go to Registry Editor and find key

1 HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Services/memcached  Server .

Change the ImagePath entry to:

1 “C:/memcached/memcached.exe” -d runservice -m 512

This way you will use 512 Mb memory limit for your server.

Google Client auth Login with PHP and Curl

// Construct an HTTP POST request
$clientlogin_url = "https://www.google.com/accounts/ClientLogin";
$clientlogin_post = array(
    "accountType" => "HOSTED_OR_GOOGLE",
    "Email" => "yourgoogle@email.com",
    "Passwd" => "yourgooglepassword",
    "service" => "writely",
    "source" => "your application name"
);

// Initialize the curl object
$curl = curl_init($clientlogin_url);

// Set some options (some for SHTTP)
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $clientlogin_post);
curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);

// Execute
$response = curl_exec($curl);

// Get the Auth string and save it
preg_match("/Auth=([a-z0-9_\-]+)/i", $response, $matches);
$auth = $matches[1];

echo "The auth string is: " . $auth;
// Include the Auth string in the headers
// Together with the API version being used
$headers = array(
    "Authorization: GoogleLogin auth=" . $auth,
    "GData-Version: 3.0",
);

// Make the request
curl_setopt($curl, CURLOPT_URL, "{Google service feed link}");
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_POST, false);

$response = curl_exec($curl);
curl_close($curl);

// Parse the response
$response = simplexml_load_string($response);

echo "<pre>";
print_r($response); 
echo "</pre>";

Google Motorola

為了搶專利,Google 死都要用 125 億美元買下摩托羅拉移動?

通常來說Google的收購保密做的都很爛(難道是故意的?),但這次Google終於做到了Apple式的保密性,他們剛剛宣佈(Larry Page作為CEO親自發的博文)以125億美元買下摩托羅拉移動(Motorola Mobility)。

摩托羅拉有80年的通訊技術歷史,也是在大概30年前首個推出世界上第一款移動電話StarTAC的公司。2007年Google宣佈Android之時摩托羅拉也是首批加入開放手機聯盟的成員之一,至此之後推出了大量的Android手機,尤其是Droid系列更是將摩托羅拉從衰落的邊緣拉了回來。

Google稱此次收購不會對Android作為一個開放平臺產生任何影響,摩托羅拉也繼續會以授權的形式使用Android(意思是Google不會開小灶兒),而Android也會保持開放(不會對別家使用Android產生影響)。Google稱會繼續讓摩托羅拉移動以一個獨立的業務運營。

此次收購顯然是針對Apple和微軟針對Android設備製造商進行專利訴訟之舉,摩托羅拉有著厚重的歷史積澱,手握大量移動領域的專利,理論上Apple和微軟無法再以此威脅Android,因為摩托羅拉手上也有Apple和微軟所沒有的專利,大家兩敗俱傷就沒有意義了。當然手握摩托羅拉專利之後,Google可以將這些專利轉移授權給HTC等專利匱乏的Android手機製造商,幫他們抵禦Apple和微軟的“流氓行徑”(至少Google認為他們是流氓的)。