Sunday, November 21, 2010

PHP on IIS7 on Windows 7 Home Premium

As a follow-up on my previous post, here's how to set up PHP 5.3.3 VC9 (MSI) on your newly enabled IIS7 on Windows 7 Home Premium

(The reason I'm emphasizing on Windows 7 Home Premium is because the Windows 7 Ultimate machine I have at work doesn't seem to have these kinds of problems)

Now if you run setup normally, you'd run into some weird error after selecting IIS FastCGI
Cancel PHP's setup and go back to

Start -> Control Panel -> Programs -> Turn Windows features on or off

Expand Internet Information Services -> World Wide Web Services -> Application Development Features and check CGI
Click OK and reboot your machine

Run PHP's setup again and select IIS FastCGI again. The install should go through normally now.

Enjoy!

Enable IIS7 on Windows 7 Home Premium

So I got this new PC and wanted to do some WAMP (Windows, Apache, MySQL, PHP) work on it. After 10+ years of Win XP, here I am with a Windows 7 Home Premium.

Installed Apache 2.2.17 and PHP 5.3.3 VC6 but couldn't get the 2 to talk to each other. (Apache insisted it couldn't find the PHP module)

I figured it was some bizarre permission issue that I didn't want to lose sleep over. (If you can't find something on Google within 15 minutes, it's a lost cause.)

So, I turned around and decided to try a WIMP instead. Windows, IIS, MySQL, PHP

Enough backstory. Here's how to enable IIS7 on Windows 7 Home Premium:

Start -> Control Panel -> Programs -> Turn Windows features on or off
Check the Internet Information Services once.
It'll default to a filled checkbox with the default options. It was good enough for me (for development work, not a live machine)
Click around to see what else you may need
Click OK

Windows may say it needs to restart. Go ahead.

Open up your web browser and type in http://localhost/ and the big ol' IIS7 image appears. The default root is in C:\inetpub\wwwroot\

Steps beyond this (eg: configuration, etc) is beyond the scope of this blog post.

Enjoy!

Monday, November 8, 2010

Compare MS SQL Databases

Found a tool today to help me deploy codes just that little bit faster by comparing 2 MS SQL databases.

Here's the link:

It's Freeware!

I don't think it will ALTER your databases for you. It just compares the DB structure. Doesn't compare data either, I think.

You have to resolve the differences manually and that's the way I like it.

Wednesday, November 3, 2010

MS SQL Fast SELECT a Random Row

Found this bit of code for MS SQL to quickly SELECT a random row from a table of millions of records.

SELECT TOP 1 *
FROM table_name
WHERE Primary_Key_ID = (SELECT CEILING(MAX(Primary_Key_ID) * RAND())
FROM table_name)

This is faster than the usual ORDER BY NEWID() as this method creates a temporary table (or view) with an additional column of NewIDs

The downside is that, if you have gaps in your Primary Key, you should take care of the statement returning blank rows in your code.

Friday, October 8, 2010

Dell Zino HD Windows Experience Index

Processor: 5.2
RAM: 5.9
Graphics: 3.6
Gaming Graphics: 5.2
Primary Hard Disk: 5.9

Wednesday, October 6, 2010

Posting to a Facebook Page

Just spent 6 hours with the new Facebook Graph API to figure out how to post to a Facebook Page.

Firstly, you need to register an app to get the App ID and Secret Key
(the basic app registration process is dead simple now. 2 textboxes, a drop down list and a submit button!)

This is for the portion that says "This is my status update - 6 minutes ago via Your App Name"

On the developer's end, you need to do 2 things:

1 - Provide a link for the user to click to log in to Facebook / authorize your app with the relevant permissions
a) Facebook Authorization Docs: http://developers.facebook.com/docs/authentication/
b) Extended Permissions: http://developers.facebook.com/docs/authentication/permissions/

2 - Provide a page for Facebook to return to once the User has logged in / authorized your app
a) Facebook will return the access token (code) that the developer can use to manipulate user data

Extended Permissions
==================
Seems that the 2 minimum extended permissions you will need are publish_stream and manage_pages. This should come under the "scope" querystring when doing the Authentication link, as mentioned above.

Get the authenticated User's accounts details
Note that "Accounts" refers to the Pages that the User administers
"https://graph.facebook.com/me/accounts?access_token=" + strAccessToken

Account details will return Page ID, Name, and Page Token

Note that the Page Token is different from the User's Token in the sense that if you POST something to Facebook using the User's token, the User will be reflected as the one contributing the POST. Example, "Muhammad Yussuf posted an update".

When you use the Page Token, it will look like this instead: "[Page Name] posted an update"

Publishing to Facebook Reference:

Facebook User Setup
====================
The only requirement to this is that the User must be the Owner / Creator of the Page to impersonate it. That means, the average Facebook user does not have any data under the "accounts" API call.

Other Notes:
=====================
The Facebook Graph API returns JSON only. So it's a bit of a headache to integrate with C#. Google for JSON.NET at CodePlex

Sunday, February 7, 2010

Guess What? I Just Completed Warcraft 3

With all the amount of people playing DOTA these days, I picked up an old copy of Warcraft 3 and started playing.

I realized I never really finished the Night Elf campaign. And now I have.

After so many years.

And just in time too. The PC died again today. Sigh.

Friday, January 8, 2010

What We Did

It's funny 'cos it's true. - http://xkcd.com/674/

Sunday, January 3, 2010

Two Zero One Zero

The future is here... so where are the robots and flying cars?