Saturday, July 23, 2011

Library Book Sale

Today, I judged books by their covers.

They were categorized in broad categories in piles and with 2 kids in tow, I had not much time to browse.

The word "bicycle" on the cover? Grab.

Terry Pratchett? No brainer. Grab.

Jim Butcher / Dresden? Grab.

Grabbed John Saul for the wife.

Grabbed a book with a nice, red cover. No idea what's in it.

...and a couple more I'm sure I won't get around to reading.

But hey, $2 a book!


Friday, July 22, 2011

Going Home!

Sure is nice to go home while the sun is still shining - on a Friday too!


Monday, May 30, 2011

PortQry - The Ping For Ports

Need to find out if your port is correctly configured? Try portqry from Microsoft. It's command line and straightforward to use.


How to use:

Sunday, May 22, 2011

Wednesday, March 16, 2011

Building a Build Machine

So, these past couple of weeks, I've been tasked with building a build machine.

What's a build machine?
A build machine should automagically build your code project into something that is usable. Actually, the complete flow should be:
  1. Get Latest Codes
  2. Build Codes
  3. Deploy
  4. Test
  5. Logging
  6. Reporting
Since the keyword here is automated, that means a Scheduled Task is involved, to be executed every night so that developers can come in the next day to see how their project has performed overnight and maybe fix bugs that their new code may have introduced.
Developers go home.
Repeat.

For this post, I will concentrate on automating the first 2 tasks:
  1. Getting the latest codes; and
  2. Building codes
== THE BUILD ENVIRONMENT ==
Lucky for me, I have a dedicated machine and multiple VMs to play with, so here's the specs of my Build Machine, for a Microsoft .NET Framework 3.5 C# Web Projects:
  1. A clean install of Windows Server 2008 Standard Full x64
  2. Set it up with a Role of a Web Server with default IIS7 settings.
  3. Get the latest copy (in my case, version 3) of Microsoft's Web Platform Installer from http://www.microsoft.com/web/downloads/platform.aspx
  4. Use it to install .NET Framework 3.5 SP1


Since automating everything will probably involve several different products (eg: SVN, Microsoft Build, Deployment, FTP, etc), executing a single batch file (.bat) seems to be the best bet.

== STEP 1: GET LATEST CODES ==
Getting the latest codes is the easiest of all the above-mentioned steps, if you're using SVN.

Get the SVN command-line client from CollabNet: http://www.open.collab.net/downloads/subversion/

The command to get the latest codes is, for example:
svn checkout https://PathOfRepository C:\ProjectPath --username MyUsername --password MyPassword

There are tons of SVN commands and options.
It's well documented and has lots of real-world examples online.
Go Google it for more details.

== STEP 2: BUILD CODES ==
If you've installed .NET Framework 3.5 SP1 correctly and successfully, check out this path in Explorer:
C:\Windows\Microsoft.NET\Framework\v3.5\

You should have a nice MSBuild.exe sitting there.
No need for a copy of Visual Studio to build your project.

To build, use the following line:
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe C:\ProjectPath\MyProject.csproj

Again, MSBuild.exe can either build the Project or the Solution, so this also works:
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe C:\ProjectPath\MySolution.sln

It depends on how your Project or Solution is set up.
You will probably need to tweak your Solution or Project file, by setting up Dependencies or References in Visual Studio (the GUI really helps, instead of tweaking the csproj or sln file by hand) before MSBuild.exe performs the way you want it.

== BUILD TIPS ==
The /target or /t flag
Since I am automating a build for an end-product, I set my /target flag like so:
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /t:Rebuild C:\ProjectPath\MyProject.csproj

I use Rebuild so that MSBuild.exe always deletes old binaries and dependencies before rebuilding them.
This may take up some extra CPU cycles, but ensures that you are always building and referencing the latest codes.

The /property or /p flag
Again, since I am automating a build for an end-product, I add on my /property flag like so:
C:\Windows\Microsoft.NET\Framework\v3.5\MSBuild.exe /t:Rebuild /p:Configuration=Release C:\ProjectPath\MyProject.csproj

This ensures that the build is in a "Release" configuration, rather than a "Debug" build or some unknown, default build configuration.
Also, since this is a clean install of Windows, adding this Configuration=Release might throw an error, with an error message that looks something like a path not found.
(I forgot what was the exact error was).

Look for the missing path in your Development environment and copy it into the build machine. This should solve it.

MSBuild.exe has a ton of options, and is probably documented by developers (read: not user-friendly!) and not many real-world examples online.

Good luck using this tool!

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?

Sunday, November 22, 2009

Attack Of The 7 Year Old PC

Success! My PC's up and running again after buying a generic power supply ($40) from CyberActive at Sengkang Compass Point.

It's been down for almost a year as I simply couldn't find the time to go and buy one.

I have totally forgotten what crappy specs it has.

Gotta get some new parts so I can install Windows 7 RC and enjoy Aero.

2 x 1GB DDR SDRAM 266MHz at $50 each
Currently, BIOS says I have 768MB RAM.

Largest 3.5" IDE HDD I can find:
500GB at $80

A new LAN card $20
I have no idea where my current LAN card or it's driver comes from. Windows 7 and Google can't find the drivers either

That's $200 to run an OS that WILL die in March 2010

Now I'm wondering if it's worth it

Monday, November 16, 2009

Work Stuff: System.Net.Mail Notes

Spent a rainy afternoon wrestling with Windows Server 2008, IIS 7

First Error:
System.Net.Mail.SmtpException: Failure sending mail. ---> System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: No connection could be made because the target machine actively refused it 127.0.0.1:25
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.ServicePoint.ConnectSocketInternal(Boolean connectFailure, Socket s4, Socket s6, Socket& socket, IPAddress& address, ConnectSocketState state, IAsyncResult asyncResult, Int32 timeout, Exception& exception)
--- End of inner exception stack trace ---
at System.Net.ServicePoint.GetConnection(PooledStream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
at System.Net.PooledStream.Activate(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDelegate asyncCallback)
at System.Net.PooledStream.Activate(Object owningObject, GeneralAsyncDelegate asyncCallback)
at System.Net.ConnectionPool.GetConnection(Object owningObject, GeneralAsyncDelegate asyncCallback, Int32 creationTimeout)
at System.Net.Mail.SmtpConnection.GetConnection(String host, Int32 port)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at webservice.sendNotification(Int32 iAppID, String strFromUID, String strToUID, String strMessage) in c:\inetpub\wwwroot\webservice.ashx:line 1001

Solution: Go to Services and make sure the SMTP Service is running (Don't trust the Feature Manager)

Second Problem:
System.Net.Mail.SmtpFailedRecipientsException: Unable to send to all recipients. ---> System.Net.Mail.SmtpFailedRecipientException: Mailbox unavailable. The server response was: 5.7.1 Unable to relay for nickfurry@live.com
--- End of inner exception stack trace ---
at System.Net.Mail.SmtpTransport.SendMail(MailAddress sender, MailAddressCollection recipients, String deliveryNotify, SmtpFailedRecipientException& exception)
at System.Net.Mail.SmtpClient.Send(MailMessage message)
at webservice.sendNotification(Int32 iAppID, String strFromUID, String strToUID, String strMessage) in c:\inetpub\wwwroot\webservice.ashx:line 1001

Solution:
SmtpClient objClient = new SmtpClient();
objClient.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
objClient.Send(objMail);

The Delivery Method is the key.

Wednesday, November 11, 2009

Heroic Dinosaurs


The real reason they're extinct

Saturday, October 31, 2009

It Was A Dark And Stormy Night

It was a dark and stormy night, almost a conclusion to the long day I've had. But the day was not yet done with me.

The Mrs was sick, Sarah's fever had shot up overnight and Johan got his new nickname, "Grumpy Bear".

All alone and awake, after everyone has had their drowsy medicine, I decided to check in on Sarah in her room, to see how she was doing.

I opened the door and a careful glance told me she wasn't in her bed or mine. Since it was very dark, I entered the room silently and carefully explored the beds with my hands...

"Just a bunch of pillows and blankets," I thought. "The Mrs must have picked her up into her room. Or she got up and wandered in."

Knowing that the Mrs was in no state to take care of Sarah, Johan and herself that night, I went into her room with the intention of "kidnapping" Sarah back. The night light in the room was on. The Mrs was sleeping soundly with Johan beside her. There was no sign of Sarah.

Concerned and puzzled, I stepped into the room for a closer look. As quietly as I could, I searched the room. Johan was there. My wife was there. Asleep. Looked at the corners of the room: nothing. Checked the master bedroom bathroom: nothing.

Fought the urge to wake my wife up and ask her where Sarah is.

Went out, closed the door behind me and went back to Sarah's room and turned on the light. No Sarah on the bed.

Went into the hall, checked her play area. Nothing. Into the kitchen. The bathroom. Nothing. Opened the front door and checked her shoes. All accounted for. And the gate was locked.

Earlier in the evening, Sarah finally managed to open up the unlocked gate by herself, put on her slippers and wandered out. A small scare, but I caught her just in time.

A small lightbulb went off over my head.

I went back to her room, climbed into bed and examined the tiny gap between my bed and the wall.

There she was, face down and quiet, almost halfway under the bed.

Always fearing the worst, I checked her body temperature and for signs of breathing. She's alive!

Somehow, I managed to carefully pick her up from the cramped space without waking her up and settled her into her own bed.

Then I settled into my own bed and blogged about it.

Sunday, October 25, 2009

The Next Singapore IT / PC / Computer Show

So... how do you plan to blow your cash away? By following the annual IT / PC / Computer show timetable of course!

March

June

September

November

Did I miss any?