Archive for Windows

AWS Management Console is nice

If you want to play with Amazon cloud computing stuff, I think using AWS Management Console web interface is the best, easiest, and most intuitive approach, based on my experience so far.

My usage with Amazon Web Services has been only with EC2 up to this point. Prior to AWS Management Console, I had to set up Java, EC2 API tools, various path and environmental variables, certificates, keys, etc., etc.. It is a fairly convoluted process.

AWS Management Console is much easier, except for downloading PuTTY and PuTTYgen on Windows and tsclient on Linux, and a private key pair, everything else is handled inside the browser. Here are a few things I learned:

  • Once you are in, create a Key Pair. The web interface will prompt you to save it. Do so, because you will need it to start instances and, depending on what type of instances you start (Windows or Linux), you will need it for shell access (Linux) or for getting Windows administrator password for remote desktop access;
  • If you are working with Windows machine running Linux EC2 instances, get PuTTY and PuTTYgen. Follow instructions here to generate key that can be used by PuTTY. It worked for me. I got my private key pair file on Linux first, and then moved to Windows. It even worked with the ^M characters inside the file.
  • For security groups, I found the ones proposed by Amazon works fine. For instance, for a typical LAMP server, it proposes a webserver group where it opens up SSH port 22, MySQL port 3306, and HTTP port 80, which is normally what you want.

Good luck!

Comments (2)

In search of a better dev environment setup

Now my make-shift working area is no longer the dining table after the move, I am eager to set up a proper environment for learning and developing software at home.

My thought is to have one decent computer that powers a few virtual machines. I like the idea of virtual machines as opposed to physical ones, which are more costly and messy. And I was pretty determined to run a Linux distro as the host, because I want to live and breathe in it for a while, to bring my Linux skill to a similar level of my Windows knowledge.

I’ve learned a few things during my quest for a better computer configuration. At times, it was really frustrating.

  • SSD (Solid State Disk) is nice. It provided a tangible, fairly obvious performance boost to my system. I am no longer afraid of the previously daunting prospect of long running install and uninstall, such as SQL Server. Better yet, when I want to test something that can potentially have a negative side effect, I now would do it in a virtual machine. Before such test starts, I take a snapshot. Prior to SSD, it would take a long time to do a snapshot of the VM. With SSD, it is much quicker now. If the test didn’t go well, I would roll back the virtual machine to the state when snapshot was taken;

    Begin rant

  • So far I am disappointed with all Linux distro that I’ve tried. Part of it is understandable, as vendors will make their devices working on Windows as a priority. I remember clearly the frustration I had when trying to get dial-up modem work properly on Red Hat, and my struggle later with wireless card. But things like these are inexcusable:

    1. Mouse freezes up for no apparent reason. When that happened, I always had to do a hard shutdown. Yes, I’ve tried various ways to restart X, but a) it didn’t work; b) Even if it worked, I would not take it. Please spare me the lecture of always using keyboard all the time. This is the deal breaker for me;
    2. Sound card stopped working after some system update from Ubuntu’s repository;
    3. Wireless card is flaky. It does not work on a consistent basis, in other words;
    4. System updates broke my display driver. I was forced to use a lower resolution display than what the monitor is capable of. I think if I recompile, I could fix it, but I was so pissed off that I didn’t bother;
    5. I couldn’t enable file sharing. It told me to resolve some dependency issues, but there were none!
    6. Ubuntu comes with Firefox 3.0, and there is no decent way of upgrading it to Firefox 3.5, other than Ubunzilla, but I cannot install Ubunzilla because the aforementioned dependency issue! And if I use apt-get install firefox-3.5, why deliver Firefox 3.0, 3.1, and a beta version of 3.5?
    7. Could we please stop using code names like Hardy Heron, Intrepid Ibex, and Jaunty Jackalope? Use that internally is fine. Version number 8.04, 8.10, and 9.04 will do for the general public.

  • After my frustration with Ubuntu, I decided to try Fedora and suseLinux (both gnome and kde). Maybe I didn’t give them enough time, but I encountered mouse and windows freeze issue as well. Ditto for Kunbuntu.

    End Rant

So I came back to Windows. Now the host runs Windows 7 Enterprise with VMWare virtual machines running Windows XP and Linux Mint 7, which looks anesthetically pleasing to me, for now.

For virtual machine software, I am using VMWare Workstation 6.5. I’ve looked at and tested a few other choices: Xen, Microsoft hyper-v, Virtual PC, Virtual Server. And VMWare Workstation came out on top, in my personal opinion. I plan to give VMWare 180 bucks for a license.

PS. I tested VirtualBox before and was reasonably impressed. I really hoped I could use it at home. But it will not make the cut, I am afraid. Read Emilian’s great critique here. I just want to add, in addition to snapshot issues, I had trouble getting the shared folder working.

Should I try FreeBSD as host?

Comments

Running Windows without anti-virus software

I’ve been frustrated with anti-virus software for a while. At a client last year, I had to fight with Symantec to get a proper ASP development environment up and running. At home, I’ve used AVG, avast, McAfee, and others. Far from the feeling of being protected from the “scary world out there”, I started to view the scanning, listening, warning, and even “calling home” “features” of anti-virus software as hindrance to my daily digital life. Granted, anti-virus software probably needs to do those kind of things, but it needs to get out of the way!

After reading similar complaints on Stackoverflow.com, I decided to follow a few others and started running Windows XP and Windows 7 without any anti-virus software. I’ve run a virus-free and anti-virus-free Windows XP machine for close to a year now, in addition to a few virtual XP machines. Also, the home Windows 7 machine has also been running naked for a few weeks now without issues.

Here are a few things I do or don’t do:
1. Browser: I use Firefox and Chrome. When running Firefox, I use adblock plus plug-in;
2. When installing software, I always pick custom installation, and I uncheck all un-necessary features;
3. Exercise good judgement.

Comments (1)

Geeky notes: monitors, WinSplit, PrintServer, Intel SSD

Long time no see, dear reader.

Quite a few things have happened. Frankly, I feel pretty drained in the last a year or two. Lately, I’ve spent time pondering about some metaphysical questions, such as the meaning of life, identity issues, and things of that nature. Hopefully those thinking will make me a better human being. I may write some of that out, time permitting. In the meantime, here is some technical notes for my own recordkeeping. Hopefully this benefits somebody, somehow.

  • I’ve used dual monitors at past employers, and didn’t find the productivity increase that were mentioned by a lot of people. When having two monitors, I found that my eyes lost “the center of attention”, so to speak. Maybe 3 monitors would have been better, but that sounds pretty expensive, overly complicated, and messy.
    So after our move and donating away our 7-year old HP CRT monitor to Salvation Army, I finally decided to move to the flat-panel age and bought a Dell LCD. I’ve also thought about acquiring a large LCD (I’ve heard people using 30 inch ones), but a few visits to computer stores convinced me that a 30 inch is just way too big. So after further research, I settled for a Dell S2409W. I also bought the AX510PA1 Sound Bar (speakers) that hangs under the LCD, which was pretty nice.
    Now this (the single LCD setup) is just my own experience. Your mileage may vary. Update: I bought my Dell monitor directly from Dell on its web site, and received a much bigger discount than if had I bought it at Microcenter. So it pays to surf around for a better price.
  • With a bigger monitor, it is important to have an easy way to manage the real estate space. Enter WinSplit. I particularly like the Ctrl-Alt-NumberPad key combination: 1 is lower left hand position, 9 is upper right hand position, 5 is center, etc. The layout of these positions correspond to the number pad layout, very intuitive. Keep pressing Ctrl-Alt-Number will toggle between different window size, very neat. For the window that gets my focus, I will use Ctrl-Alt-5 a few times to put it in the center and get the size I like, usually taking perhaps 2/3 of the screen. I can still monitor the other windows with side glances, if I want to.
    It would be very nice to have a WinSplit type application for Ubuntu. I haven’t done much googling on that yet. Any recommendations, dear reader?
  • After the move, the family machine will be a generic, no-brandname black box, close to 10 years old. So natually it does not support DVI, not to mention HDMI. The funny thing was when I put Ubuntu on this machine with VGA connection to the newly acquired S2409W, the screen looks sharp and nice. But with Windows 7, pictures look a bit distorted. I had to purchase a EVGA e-GeForce 8400 GS 512MB DDR2 PCIe Graphics Card, which has DVI support, for it to support Windows 7 properly. Windows 7 seems to work pretty well, though.
  • Now our place is bigger than 75 square meters, we have room for a small office. Toward that end, I bought a DPR 1260 print server to hook it up with our existing EPSON RX600 printer. DPR 1260 is a wireless printer server device that make the printer available to all PCs in the house. So far I am pleased with it. My Ubuntu laptop can print from it, but I haven’t figured out how to make it scan. (Update: after choosing some different options on the web interface, I could scan with Ubuntu also, it’s just a bit slower). I can scan with Windows machines, though. I thought the wireless print server was pretty neat.
  • Intel X-25M SSD is really nice. It makes my Ubuntu laptop much responsive than before. I settled on X-25M after some reading on the web. I’d like to hear real world SSD experience with different brands, such as OCZ, PNY, and Samsung.
    If your PC has SATA hard drives and you are considering upgrading, I’d highly recommend a SSD upgrade.
  • Lastly, I am working with a great partner on developing a software product. I will definitely write more about it in the future.

Comments

Installing Windows 7 on Samsung N120 Netbook

Installing software on a netbook is tricky, as there is no CD/DVD-ROM drive on it. One could buy a usb-attached CD/DVD-ROM for it. It is also possible to do it with usb thumb drive and usb disk drive. I have Western Digital’s usb disk drive, and that was what I used to install Windows 7 on a Samsung N120 netbook. From what I can tell, it really does not make a difference which type of usb devices you use. I tried to use a SD card, as I have an adapter that can connect the SD card to the computer through a usb port, but that didn’t work, since the it is not recognized as a disk drive.

Initially I tried to properly format the usb disk drive with diskpart utility, but that didn’t work because the diskpart in Windows XP does not have the format command, unlike that of Vista and Windows 7. I tried that anyway, but got messages like “NTLDR Is Missing” or “Operating System Not Present” when trying to boot.

Finally I followed instructions here. It went farther than before, but I constantly got the acpi.sys blue screen of death error.

The way to get around that is to disable Processor Power Management in the BIOS. After that, installation proceeded without errors, but it took a long time. I don’t know how long, because after babysitting it for a while, I went to bed and came back to it the next morning.

Based on my limited experience, Windows 7 RC on this netbook is a disappointment. I installed Enterprise Edition, but it was very unstable: wireless connection was flaky, even a simple task of switching windows would take a long time, etc.. For now, I am using factory default, sans anti-virus software, Windows XP Home Edition, and it has been pretty snappy so far. Granted, Windows 7 is beta software, so hopefully the final release will work better, with proper drivers and such.

Comments (5)

Masking a CSV file through shuffling

I wrote a bit on data masking here. Below is a simple C# program to reshuffle data in a csv file. It uses FileHelpers library for the .Net Framework.

To play with this simple code, first download FileHelpers library. Then save the text below the C# code into a file, modify the code to so it points to the text file you just saved. And it should work. Nothing fancy, just a proof of concept kind of work.

using System;
using System.Collections.Generic;
using System.Text;
using System.IO;
using FileHelpers;

namespace FileTest
{
    class Program
    {
        static Random randomNumber = new Random();
        static void Main(string[] args)
        {

            FileHelperEngine engine = new FileHelperEngine(typeof(People));
            engine.Options.IgnoreEmptyLines = true;
            People[] res = engine.ReadFile(@"c:\junk\PeopleName.txt") as People[];
            for (int i = 0; i < res.Length; i++)
            {
                //Console.WriteLine(GenerateRandomString(9) +
                    Console.WriteLine(res[randomNumber.Next(res.Length)].FirstName +
                    res[randomNumber.Next(res.Length)].LastName);
            }
        }
        public static long CountLinesInFile(string fileName)
        {
            long count = 0;
            using (StreamReader reader = new StreamReader(fileName))
            {
                string line;
                while ((line = reader.ReadLine()) != null)
                {
                    count++;
                }
            }
            return count;
        }
        public static string GenerateRandomString(int intLenghtOfString)
        {
            //Create a new StrinBuilder that would hold the random string.
            StringBuilder randomString = new StringBuilder();
            //Create a new instance of the class Random
            //Create a variable to hold the generated charater.
            Char appendedChar;
            //Create a loop that would iterate from 0 to the specified value of intLenghtOfString
            for (int i = 0; i <= randomNumber.Next(1, intLenghtOfString); ++i)
            {
                //Generate the char and assign it to appendedChar
                appendedChar = Convert.ToChar(Convert.ToInt32(26 * randomNumber.NextDouble()) + 97);
                //Append appendedChar to randomString
                randomString.Append(appendedChar);
            }
            //Convert randomString to String and return the result.
            return randomString.ToString();
        }
        [FixedLengthRecord(FixedMode.AllowLessChars)]
        class People
        {
            [FieldFixedLength(9)]
            public string FirstName;

            [FieldFixedLength(14)]
            public string LastName;

            [FieldFixedLength(27)]
            public string Address1;

            [FieldFixedLength(18)]
            public string City;
        }
    }
}
Robert   Foster         123 Roosevolt Ave.         Chicago
Edward Smith 93874 Madison Oak Park
James Kane 324 Grant Geneva
Mei Liu 587 Lincoln River Forest
Jane Doe 6565 Truman Maywood
Peter Imanov 456 Wilson Berkeley
Daming Wang 897 Jackson Aurora
Spiro Agnew 233 Jefferson Naperville
Osama BinLaden 6431 Kennedy Arlington Heights
George Bush 2356 Grant Evanston
Dick Cheney 6498 Coolidge Skokie
Barack Obama 8439 Adams Glenview

Comments

Random oddity

Recently I wrote a program to reshuffle data in a csv file. And I ran into a problem with Random in C#.

Let’s look at the following program. One would think that it should print 5 integers, randomly picked between 0 and 8. But no, in almost all cases, the program prints the same integer 5 times.

using System;
class Scaffolding
{
    static void Main(string[] args)
    {
        for (int i = 0; i < = 5; ++i)
        {
            Random randomNumber = new Random();
            Console.WriteLine(randomNumber.Next(9));
        }
    }
}

It turns out the correct way, and more efficient way according to documentation, is to instantiate one static Random class to generate many random numbers over time, instead of repeatedly creating a new Random to generate one random number, like so:

using System;
class Scaffolding
{
    static Random randomNumber = new Random();
    static void Main(string[] args)
    {
        for (int i = 0; i <= 5; ++i)
        {
            Console.WriteLine(randomNumber.Next(9));
        }
    }
}

MSDN documentation is here.

Comments

Sql Server database mirroring automatic failover verification

Starting with Sql Server 2005, Sql Server provides an interesting high availability option at individual database level, called database mirroring. When configured in high availability mode (principal, mirror, and witness), provided that:

1. Failover Partner information is supplied in the connection string;
2. Application code knows to retry database operations;

then automatic fail over will occur.

This all sounds good, but seeing is believing. So I wrote a simple C# console program to simulate what happens when the principal database fails. This simple program connects to a mirrored database, grabs data, and then prints it out on the console. It is a bit contrived, and I used the somewhat dreaded goto statement to retry connections, but hopefully it demonstrated the point. I tested this on VMWare virtual machines, so I put in 1 second delay.

Here is what I tested while my console program is running:

1. Manual failover through the principal’s property page. The program didn’t skip a beat. Results below:

Haidong
12/4/2008 9:21:32 PM
Haidong
12/4/2008 9:21:33 PM
Haidong
12/4/2008 9:21:34 PM
Haidong
12/4/2008 9:21:35 PM
Haidong
12/4/2008 9:21:36 PM
Haidong
12/4/2008 9:21:37 PM
Haidong
12/4/2008 9:21:38 PM

2. Stopped Sql Server service on the principal. Similar results as above;

3. Yanked the power cable off the principal box. There was a noticeable delay. Notice the one minute delay in results below:

Haidong
12/4/2008 10:00:23 PM
Haidong
12/4/2008 10:00:24 PM
Haidong
12/4/2008 10:00:25 PM
Haidong
12/4/2008 10:01:24 PM
Haidong
12/4/2008 10:01:25 PM
Haidong
12/4/2008 10:01:26 PM
Haidong
12/4/2008 10:01:27 PM
Haidong
12/4/2008 10:01:28 PM
Haidong
12/4/2008 10:01:29 PM

All in all, I am pretty impressed. If you compile and run the program, use Ctrl – c to stop if you think you’ve seen enough. Source code below.

using System;
using System.Data;
using System.Data.SqlClient;
using System.Threading;

namespace SqlDbConsole
{
    class Program
    {
        [STAThreadAttribute]
        static void Main(string[] args)
        {
            while (true)
            {
                RunSimpleSql();
            }
        }
        static void RunSimpleSql()
        {
            SqlConnection conn = new SqlConnection("Data Source=PrincipalServer;Failover Partner=MirrorServer;Initial Catalog=MyDb;Integrated Security=SSPI;");
        PointOfRetry:
            try
            {
                conn.Open();
                SqlCommand cmd = conn.CreateCommand();
                cmd.CommandText = "SELECT TOP 1 FirstName from Contact";
                cmd.CommandType = CommandType.Text;

                SqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read() == true)
                {
                    string s;
                    s = (string)rdr["FirstName"];
                    Console.WriteLine(s);
                    //Console.WriteLine("Beijing: {0}", TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, TimeZoneInfo.Local.Id, "China Standard Time"));
                    Console.WriteLine(DateTime.Now);
                }
                Thread.Sleep(1000);
            }
            catch
            {
                goto PointOfRetry;
            }
        }
    }
}

Comments

Notes on analyzing a user minidump with WinDbg

One of my students’ Sql Server 2000 SP4 crashed. I volunteered to see if I could get anything out of it by looking at the dump file with WinDbg.

A few notes:
1. The processor or Windows version that the dump file was created on does not need to match the platform on which WinDbg is being run. However, you do need to provide symbol files that match the Windows edition and version where the dump was from. You can have more than one symbol file path, just separate them by a semicolon.

Since the dump file was generated on Windows 2003 SP2, I downloaded symbol files for it and installed on my Windows XP SP2 laptop. Afterwards, I added it to the symbol path. So my symbols are from 2 sources: Microsoft symbol server and the local symbol I downloaded;

2. I did install Sql Server 2000 SP4 on my laptop to match the Sql Server instance on the server where the dump was from. Afterwards, I added C:\Program Files\Microsoft SQL Server\MSSQL$SQL2K\Binn to the Image File Path

After running:
!analyze -v
~kv
lm

WinDbg points to the direction of:

INVALID_POINTER_READ_c0000005_sqlservr.exe!CIncPageMgr::FreeToMark

Not too sure how revealing this is, since we’ve already known it was an access violation. I suppose those kind of information is like bread crumbs that can be helpful to Microsoft support.

Questions:

1. I thought that I got all the right symbol path, but I still got the message below in the command window, why?
excerpt
Your debugger is not using the correct symbols
Type referenced: kernel32!pNlsUserInfo

2. It looks like viewing the memory content in the last call can be helpful (Alt + 5). Two questions related to this point:
a. Which display format is useful? To me, part of ASCII and Byte are meaningful to the naked eye.
b. How can I save the memory content in a text file? I can analyze text much faster in VI, but I haven’t found a good way to suck the text out of the memory viewer window?

Got to retire now. I have close to 20 students to teach tomorrow. It was a fun teaching day today.

By the way, X.T.X (谢天笑, 冷血动物), a Shandong boy like me, is not bad.

Any help regarding my WinDbg questions, dear reader?

Comments (2)

TCP Chimney issue on Windows 2003 Service Pack 2

If you are running Sql Server 2005 on Windows Server 2003 SP2, you may get this message from Sql Server native client connection:

An existing connection was forcibly closed by the remote host

This is most likely caused by a “feature” called TCP Chimney offloading. On the server, run:

Netsh int ip set chimney DISABLED

should fix your problem. It seems Visual Basic 6 (VB6) based applications and Heat Call Logging are particularly susceptible to this problem.

KB article here: http://support.microsoft.com/default.aspx/kb/945977

Comments (3)

« Previous entries