Sunday, December 22, 2013

Install Eclipse on Mac OS/X

After I upgraded my MacBook Pro from OS/X 10.7 "Lion" to OS/X 10.9 "Mavericks", many my applications did not work correctly so I uninstalled them. Install Eclipse IDE on Mac OS/X is simple, just extract the zip file and you are all set.

How do I put Eclipse icon on launchpad?
Move whole Eclipse folder to your Applications folder

Sunday, November 17, 2013

Check for existing record before insert

To avoid duplicate record in database, it is better to check for duplicate certain column data before insert. Primary key is a good mechanic to prevent duplicate row but don't count on it. Take a look the following SQL statements.

-- Creating temporary table (Notice the primary key is set to identity)
CREATE TABLE #tblTemp
    ( ID int identity primary key,
           ColA nvarchar(30),
           ColB nvarchar(50)
        );
GO

-- Inserting new record into the temporary table tblTemp
-- If execute this insert statement twice, you will have two row have same data in ColA and ColB
-- with difference ID
INSERT INTO #tblTemp VALUES ('Test A1', 'Test B1');

-- This is better
IF NOT EXISTS (SELECT 1 FROM #tblTemp WHERE #tblTemp.ColA='Test A1')
    INSERT INTO #tblTemp VALUES ('Test A1', 'Test B1')
SELECT * FROM #tblTemp

Another example using sample database AdventureWorks2012.
USE AdventureWorks2012;
GO
SELECT * FROM AdventureWorks2012.Person.Address WHERE AddressLine1='1970 Napa Ct.';
GO

-- We don't want a duplicate record for AddressLine1 '1970 Napa Ct.' and PostalCode 1597
IF NOT EXISTS (SELECT 1 FROM AdventureWorks2012.Person.Address WHERE AddressLine1='1970 Napa Ct.' AND PostalCode=1597)
    INSERT INTO AdventureWorks2012.Person.Address (AddressLine1, City, StateProvinceID, PostalCode)
    VALUES ('1970 Napa Ct.', 'Lane Cove', 50, 1597);

SELECT * FROM AdventureWorks2012.Person.Address WHERE AddressLine1='1970 Napa Ct.';
GO

Tuesday, October 8, 2013

Error 5120 When Attached Database

I got error 5120 when attempted to attach sample database AdventureWorks2012 to Microsoft SQL Server 2012 ran on Microsoft Windows 8.1 Preview.
Solution to this problem is simple: Close the current Microsoft SQL Server Management Studio and run it as administrator to attach database. Also, do not use 'sa'. Use Windows Authentication instead.
Now, test it as normal user by update a record in the AdventureWorks2012 database.

Tuesday, September 17, 2013

Microsoft SQL vs MySQL

I'm working with both databases and love them. Here are my notes their SQL syntax difference.

Select first 10 records from table:
In Microsoft SQL:
SELECT TOP 10 SchoolID, SchoolName
FROM schools
ORDER BY SchoolID;

In MySQL:
SELECT SchoolID, SchoolName
ORDER BY SchoolID
LIMIT 10

Create new table and insert data from existing tables
Microsoft SQL:
SELECT * INTO Schools_Bak20130916 FROM Schools;

MySQL:
CREATE TABLE Schools_Bak20130916 SELECT * FROM Schools;

Saturday, August 17, 2013

GPS & CELL PHONE

Got this story by email, don't know it's true or not.  But somethings are useful. Here are my suggestions: 
  1. First, alway think twice before click on any link or text back.
  2. Second, put your password on your cell phone or any mobile devices such as tablet, iPad, iPod Touch.
  3. Third, make a new email to use on smart phone only. In case your phone lost or stolen, people cannot use that email to reset your account password.
  4. Last, don't put you home address, birthday on your address book, Facebook, LinkedIn or anything not necessary. When I search for map direction on the web, I used the public location nearby such as school, store or supermarket as my home address.
* * * * * 

This gives us something to think about with all our new electronic technology.

GPS

A couple of weeks ago a friend told me that someone she knew had their car broken into while they were at a football game. Their car was parked on the green which was adjacent to the football stadium and specially allotted to football fans. Things stolen from the car included a garage door remote control, some money and a GPS which had been prominently mounted on the dashboard.

When the victims got home, they found that their house had been ransacked and just about everything worth anything had been stolen. The thieves had used the GPS to guide them to the house. They then used the garage remote control to open the garage door and gain entry to the house.

The thieves knew the owners were at the football game, they knew what time the game was scheduled to finish and so they knew how much time they had to clean out the house. It would appear that they had brought a truck to empty the house of its contents.

Something to consider if you have a GPS - don't put your home address in it.. Put a nearby address (like a store or gas station) so you can still find your way home if you need to, but no one else would know where you live if your GPS were stolen.

MOBILE PHONES

I never thought of this.......

This lady has now changed her habit of how she lists her names on her mobile phone after her handbag was stolen. Her handbag, which contained her cell phone, credit card, wallet... Etc...was stolen.

20 minutes later when she called her hubby, from a pay phone telling him what had happened, hubby says 'I received your text asking about our Pin number and I've replied a little while ago.' When they rushed down to the bank, the bank staff told them all the money was already withdrawn. The thief had actually used the stolen cell phone to text 'hubby' in the contact list and got hold of the pin number. Within 20 minutes he had withdrawn all the money from their bank account.

Moral of the lesson:

Do not disclose the relationship between you and the people in your contact list.

Avoid using names like Home, Honey, Hubby, Sweetheart, Dad, Mom, etc....

And very importantly, when sensitive info is being asked through texts, CONFIRM by calling back

Also, when you're being texted by friends or family to meet them somewhere, be sure to call back to confirm that the message came from them. If you don't reach them, be very careful about going places to meet 'family and friends' who text you..

Monday, July 15, 2013

Using Visual Studio 2013 Preview and Team Foundation Service

Back to Microsoft Windows stuff. To maintain my program skills, I alway learn a new thing, practice what I learn and review what I did. This time I work with ASP.NET by using Visual Studio 2013 Preview on Microsoft Windows 8.1 Preview with Microsoft Team Foundation Service, a free TFS on the cloud.

Wednesday, July 3, 2013

Learning ColdFusion 10

Temporary hold my current projects: Microsoft C# ASP.NET MVC and Google Android Demo App for a week to try out Adobe® ColdFusion® 10 Developer edition and MySQL 5.6.12. I love the opportunity to learn a new thing.


Install Adobe ColdFusion 10 Developer edition on Microsoft Windows.

Install MySQL 5.6.12

Using GitHub on Windows for version control.