Carl’s Geek Notes

November 20, 2009

Windows Drag & Drop not working

Filed under: Computers, Windows Administration — Tags: , , — Carl @ 8:17 am

My Windows XP Pro computer developed an interesting problem… Drag and drop stopped working.  I couldn’t move emails between folders, change desktop icon position, tear out a browser tab, etc.  After a bit of searching I found a fix for it, based on this MS article:

KB274696

The basics of the article are correct; however, the steps are incomplete for XP.  Here’s an updating of the instructions:

  1. Start->Run, type dcomcnfg, enter.
  2. Expand Console Root->Component Services->Computers->My Computer.
  3. Right-click My Computer and choose Properties.
  4. Go to the COM Security tab and click Edit Default… under Access Permissions.
  5. Verify that both System and Interactive are listed with Allow Access. If either are missing, add them by clicking Add.
  6. In the List Names From box, make sure that the local computer name is listed.
  7. Type interactive or system as appropriate (mine was missing Interactive).
  8. Click OK.
  9. Make sure that Allow is checked on Local Access for both users.
  10. Click OK.

Mine immediately started working without a reboot.

March 11, 2009

iPhone Review

Filed under: Computers, Gadgets, Internet, iPhone, iPod — Carl @ 11:02 am

I’ve now had the iPhone for nearly two weeks and thought I’d provide a review of it.  I upgraded from a Treo 700p (Palm OS) on Sprint service to an 8 GB iPhone 3G.

The iPhone definitely shows its Apple heritage–sleek, rounded, and modern.  The form factor is perfect–it’s easy to hold either while looking at it or talking on it.  I like the weight of it; it’s not unwieldy but definitely has enough heft to feel substantial.  It is thin enough to very comfortably slide into a pocket, and I don’t snag it on things when it’s in my belt holster like I did with the Treo.

The iPhone interface has an attention to detail and usability that is unmatched among developers today.  The way the phone interprets flicks, taps, drags, etc. is unbelievable.  After just a few minutes’ practice, I have not had any gesture misinterpreted.  And the zoom in/out gestures are so sensible and ideal for the iPhone.  Apple’s interface has me seriously considering building my next computer as a dual-booting Hackintosh.  It’s easy to make computers and applications complex; making them simple without being dumb requires brilliance.

The downside of the Apple heritage is the sense of elitism that is nowhere more apparent than in the glossy iPhone.  My touch mars it with fingerprints as if I have sullied this piece of genius engineering by daring to use it.  I find myself continually polishing to remove the traces I have left.  (I did find some DLO screen protectors–$20 for 5 protectors at Best Buy–that keep it much cleaner than in its native state.)

The lack of tactile feedback while typing took some time to get used to, but now is no issue at all.  The auto-correct feature seems to take care of 90%+ of fat finger mistakes.

The screen is bright and clear and shows off photos very well.  I’ve loaded some favorite pictures on it and it’s handy as a quick photo gallery.  The camera on the iPhone is quite usable for snapshots–not on par with my Canon DSLR, but not bad either.  Video looks great–I’ve been showing off the iPhone by playing the intro to Top Gun and everyone is wowed by it.  Anamorphic video gives very high resolution display and is quite watchable.

AT&T coverage is substantially better than Sprint’s in my area.  My cell phone was virtually unusable at my house unless I stood near the front door or went upstairs.  I have not had a single call drop or outage spot with AT&T.  I also like the way the iPhone stays on AT&T’s data network all the time.  My Treo would have to periodically reconnect to the Power Vision network, causing a delay.

Another nice feature of the iPhone is the way that it automatically switches to WiFi when I’m at a known network for the best data speed.  This is seamless and other than the annoyance at having to switch between the alphabetic and numeric keyboards on just about every digit when entering the hexadecimal WiFi keys was no problem to set up.  I have seen a couple of times when the phone is on the 3G network when I was close enough to reach out and touch my home WiFi router.

A good deal of my data usage is email.  I quite like the email app on the iPhone–especially that it is IMAP compatible so it manipulates the mail directly on the server.  My two complaints are relatively minor.  Sometimes it spends inexplicably long showing “Connecting” when checking email and there’s no way to cancel this and re-start like I could on the Treo.  Also, it would be very nice if email could be displayed in the landscape view; some emails (especially HTML-formatted ones) are almost unreadable because of the side-to-side scrolling required.

I have found a couple inexplicable omissions.  The iPhone cannot delete only a single recent call or text message–you can clear the entire list but not just one entry.  There is no speed-dial function to call a number with one button press, it’s a couple of levels away from the phone keypad screen.  A double-click of the home button can be configured to go to the Favorites but I’d prefer that it go to the keypad.

I would also like some better application screen management.  It’s easy to get cluttered screens and a pain to organize them.  (I also find that apps are a pain to manage in iTunes.  Let’s hope a fix is on the way.)

My biggest complaint is that there is no way to quickly page up or down with one hand.  There is not enough accuracy in scrolling to do this; I find that I have to scroll very slowly while watching the line that I just read, and I can only do this by holding firmly in one hand and dragging with the other.  Otherwise I have to visually re-acquire the line that I was reading and that definitely disturbs the continuity.

The true “killer feature” of the iPhone is the App Store in iTunes.  There’s such a variety of programs available in the App Store that it’s mind-boggling.  Shazam uses the iPhone’s microphone to take a sample of music that is compared to an online database and identifies the song.  The Google app for iPhone has speech-recognition searches.  Google Maps can use the phone’s pseudo-GPS to give directions.  The Facebook app for iPhone lets you do practically everything you can from a full-size computer.  There are accelerometer-based levels, sports score applications, exercise program trackers, internet radio, e-book and Amazon Kindle programs, planet and star  trackers, the complete works of Shakespeare, and games, games, games, games, games, and more games.  And I have the feeling that we’ve only seen the tip of the App iceberg!  What’s more, you can browse and download the apps without a computer.

In a word, the iPhone is awesome.  It exceeds any expectation of mine about what a portable computing device can be.  Well done, Apple!

December 8, 2008

Run a SQL UPDATE command and return the number of affected records

Filed under: C#/.NET, Computers, Programming, SQL Server — Tags: , , — Carl @ 9:29 am

I wanted a quick way to run a SQL UPDATE command and return the number of affected rows in .NET.  Here’s the code to do it:

int RecordCount = 0;
string SQL = "UPDATE MyTable SET MyField = @MyNewValue "
    + "WHERE MyKey = @MyKey "
    + "SET @RecordCount = @@ROWCOUNT";
SqlCommand MyCmd = new SqlCommand(SQL, MyConn);

// Use an out parameter to get the number of rows affected
SqlParameter RecordCountParam = new SqlParameter("@RecordCount", SqlDbType.Int);
RecordCountParam.Direction = ParameterDirection.Output;
MyCmd.Parameters.Add(RecordCountParam);

// Add the query parameters
MyCmd.Parameters.AddWithValue("@MyNewValue", MyNewValue);
MyCmd.Parameters.AddWithValue("@MyKey", MyKey);

// Run the query
MyCmd.ExecuteNonQuery();

// Check the number of records affected
if (Int32.TryParse(RecordCountParam.Value.ToString(), out RecordCount)
{
	// Do Stuff Here
}

August 27, 2008

XmlNamespaceManager and overridden default XML namespace

Filed under: C#/.NET, Computers, Programming, Web Services, XML — Carl @ 12:22 pm

Issue: My XmlDocument.SelectNodes() or SelectSingleNode() wasn’t working correctly with the incoming XML. It was always returning null even when the element was specified.

Problem: If the XML has an overridden default XML namespace (i.e., the root node has an attribute xmlns=”urn:MyNamespace” in it), SelectNode is unable to properly resolve it.

Solution: Use an XmlNamespaceManager to give a prefix to the default namespace, like so:

string MyXML = "<?xml version=\"1.0\"?><MyElement xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"urn:MyNamespace\"><MySubElement>3</MySubElement></MyElement>";

// Create and load the XML document
XmlDocument MyDoc = new XmlDocument();
MyDoc.LoadXml(Response);

// Create a namespace manager with the XML document's name table
XmlNamespaceManager MyNamespaces = new XmlNamespaceManager(MyDoc.NameTable);

// Add namespaces for all prefixed xmlns declarations
MyNamespaces.AddNamespace("xsi", "http://www.w3.org/2001/XMLSchema-instance");
MyNamespaces.AddNamespace("xsd", "http://www.w3.org/2001/XMLSchema");

// Add the default namespace with a custom prefix
MyNamespaces.AddNamespace("MyNS", "urn:MyNamespace");

// Use the namespace manager to select the node
// Make sure that each element in the default namespace is prefixed with your custom prefix
// It is not sufficient to do MyNS:MyElement/MySubElement, both must be qualified!
XmlNode MyNode = MyDoc.SelectSingleNode("MyNS:MyElement/MyNS:MySubElement", MyNamespaces);

August 13, 2008

High-quality anamorphic video for iPod Classic

Filed under: Computers, Gadgets, iPod — Tags: — Carl @ 4:43 pm

Want to encode your DVDs in the highest possible quality for both your iPod and your computer screen?  Dissatisfied with having the 640-pixel width limit?  Discover the joys of encoding anamorphic videos for your iPod with Handbrake.

First, make sure you’re on the most recent version of Handbrake.  I used version 0.9.2, build 2008021900 for this.

Next, rip your DVD as an ISO with DVD Decrypter or similar.  Mount your ISO image and start Handbrake.  Browse to the VIDEO_TS directory on your DVD and select the appropriate title (the longest one is usually the main movie).

Make sure your destination file is .m4v–that seems to be more tag-compatible than .mov in iTunes.

Then, click on the preset for iPod High-Rez.  Ensure that the encoder is H.264 and audio is AAC.  Check the box for Insert iPod Atom.

Under the Picture Settings tab, check the Loose Anamorphic box.  Enter your width as 720.

Now, here’s the important part that is easy to overlook (and it only shows up as an error if you open the Activity Window after your encode and review it thoroughly).  Go to the Advanced tab.  Change the value for vbv-maxrate=1500 to vbv-maxrate=2500 to ensure that your video buffer keeps up with your desired framerate.

(The rest of these settings are optional, but I’ve had very good success with them.)

Under the Video tab, check 2-pass Encoding and Turbo first Pass.  Set Avg Bitrate (kbps) to 2500.  (I noticed some “stuttering”–a horizontal line scanning across the picture occasionally–at 2000 kbps but it disappeared at 2500 kbps.)

Under the Audio & Subtitles tab, set the Audio Quality Bitrate to 160 or less–I prefer 128 as I really don’t notice difference between AAC-encoded audio at 128 and 160.  Your mileage may vary, however.

Prepare to wait several hours for this to complete on a 2 hour movie (about 5 for both passes on my computer).  If you start one when you go to bed at night it will be probably be ready in the morning.

Why doesn’t this break the 640-pixel width limit?  Because you’re using anamorphic video, the same method that DVDs use to store 720 pixels of width in a 640-pixel grid.  Then the pixel aspect ratio stretches it to the appropriate width.

On videos that are enhanced for 16:9 display, you now have a video that will play on your iPod and will have 853 (or thereabouts) pixels of width once the anamorphic storage and pixel aspect ratio is taken into account.

(I believe this methodology is compatible with iPod Touch and iPhone, but I have no experience with that so I can neither confirm nor deny.  I’m fairly certain this does not work with a fifth-generation or 5.5G iPod.)

View additional properties for AD accounts

Filed under: Computers, Windows Administration — Carl @ 9:00 am

Need to find more information about an Active Directory account than is readily viewable in Active Directory Users and Computers, like last login time, last password change time, password expiration date, SID, GUID, and more? Download this handy utility:

http://www.computerperformance.co.uk/w2k3/utilities/acctinfo.htm

put it in %SYSTEMROOT%\system32, regsvr32 it, close & reopen ADUC, and look for the new tab for Additional Account Info. Very handy!

June 5, 2008

Using an object as an array accessor through Reflection

Filed under: C#/.NET, Computers, Programming — Carl @ 1:40 pm

Fun bit of code here using System.Reflection!

I have a class that contains an array of objects.  I wanted a convenient way to be able to access elements by the value of a property within the object, for example, if I have an array of type Employee and I want to find the one in the array where the LastName Property is Smith, it would be nice to be able to call MyArray["EmployeeID", "12345"] to get the item.  Basically, adding some Dictionary-type lookup options to an indexed array is what I wanted.

My solution is:

public class ccnGenericCollection<T>
{
    #region Fields
    private T[] _Items;
    #endregion

    #region Properties
    public T[] Items
    {
        get { return _Items; }
        set { _Items = value; }
    }

    public T this[int index]
    {
        get { return _Items[index]; }
        set { _Items[index] = value; }
    }

    public T this[string fieldName, object searchValue]
    {
        get
        {
            // Make sure the items and key field name are initialized
            if (null != _Items)
            {
                // Get the member 
                MemberInfo[] MyMembers = typeof(T).GetMember(fieldName);
                if ((null != MyMembers) && (MyMembers.GetLength(0) > 0))
                {
                    MemberInfo MyMember = MyMembers[0];
                    // Loop through the items
                    for (int i = 0; i < _Items.GetLength(0); i++)
                    {
                        object MyKeyValue;
                        // Get the field or property value
                        switch (MyMember.MemberType)
                        {
                            case MemberTypes.Field:
                                MyKeyValue = ((FieldInfo)MyMember).GetValue(this[i]);
                                break;
                            case MemberTypes.Property:
                                MyKeyValue = ((PropertyInfo)MyMember).GetValue(this[i], null);
                                break;
                            default:
                                throw new Exception(fieldName + " must be a field or a property");
                        }
                        if (MyKeyValue.Equals(searchValue))
                        {
                             // Found our item
                             return _Items[i];
                        }
                    }
                }
            }
            // Not found, return a default item
            return default(T);
        }
        set
        {
            if (null != _Items)
            {
                // Get the member
                MemberInfo[] MyMembers = typeof(T).GetMember(fieldName);
                if ((null != MyMembers) && (MyMembers.GetLength(0) > 0))
                {
                    MemberInfo MyMember = MyMembers[0];
                    // Loop through the items
                    for (int i = 0; i < _Items.GetLength(0); i++)
                    {
                        switch (MyMember.MemberType)
                        {
                            case MemberTypes.Field:
                                if (((FieldInfo)MyMember).GetValue(this[i]).ToString() == searchValue)
                                {
                                    // Set the item
                                    _Items[i] = value;
                                }
                                break;
                            case MemberTypes.Property:
                                if (((PropertyInfo)MyMember).GetValue(this[i], null).ToString() == searchValue)
                                {
                                    // Set the item
                                    _Items[i] = value;
                                }
                                break;
                        }
                    }
                }
            }
            // No item found, throw a null reference exception
            throw new NullReferenceException();
        }
    }
    #endregion

    #region Operators
    public static implicit operator T[](ccnGenericCollection<T> input)
    {
        // Automatically convert from an array of the underlying class to the generic collection
        T[] Output = (T[])input.Items.Clone();
        return Output;
    }

    public static implicit operator ccnGenericCollection<T>(T[] input)
    {
        // Automatically convert from the generic collection to an array of the underlying class
        ccnGenericCollection<T> Output = new ccnGenericCollection<T>();
        Output.Items = (T[])input.Clone();
        return Output;
    }

    public static implicit operator List<T>(ccnGenericCollection<T> input)
    {
        // Automatically convert from an array of the underlying class to the generic collection
        List<T> Output = new List<T>();
        if (null != input.Items)
        {
            Output.AddRange(input.Items);
        }
        return Output;
    }

    public static implicit operator ccnGenericCollection<T>(List<T> input)
    {
        // Automatically convert from the generic collection to an array of the underlying class
        ccnGenericCollection<T> Output = new ccnGenericCollection<T>();
        Output.Items = (T[])input.ToArray().Clone();
        return Output;
    }
    #endregion

    #region Methods
    public int Add(T newItem)
    {
        // Get the list of the current items
        List<T> MyList = (List<T>)this;
        // Add the new item
        MyList.Add(newItem);
        // Set the items to the array of the list
        _Items = MyList.ToArray();
        // Return the highest index of the items
        return _Items.GetUpperBound(0);
    }
    #endregion
}

This solution allows the field name for the search to be either a field or a property.

Note that it’s prudent to make sure that the field used to access the class is unique; it’ll return the first match for get and update all matches for set.

I got a surprise the first time I ran it when I never got any matches back by using MyKeyField == searchValue as the condition; I had to use MyKeyField.Equals(searchValue) to use the object equality. This also means that it’s easy to define what equality is for a given class by implementing the == operator for the class.

The implicit operators come in handy as well; basically any class that implements this class can be converted to/from arrays and lists.

March 31, 2008

The Oh-So-Useful Scroll Wheel

Filed under: Computers, Internet, Windows Administration — Carl @ 1:43 pm

Here’s a great tip for improving your surfing experience while using a tabbed browser (verified in IE7 and Firefox by me):

Clicking the scroll wheel on a link on a page opens that page in a new tab.  So now I don’t have to hold down Control to click on all the interesting links that I see in an article!

(Clicking it on the title of a tab will also close that tab.  That trick also works in Visual Studio!)

March 10, 2008

Violating Internet standards, part 2: Firefox

Filed under: Computers, Windows Administration — Carl @ 6:50 am

I wanted to do the same thing that I talked about in my “Want to Violate Internet Standards?” post in Firefox.  Here are directions:

In the address bar, type:

about:config

In the filter box that appears, type:

network.http.max-

You’ll see four settings.  The ones we want to modify are network.http.max-connections and network.http.max-connections-per-server.  Double-click these to set new values.  I did max-connections at 64 and max-connections-per-server at 16 and that made me happy with the download speed.

February 19, 2008

Perhaps you should set your sights a little higher?

Filed under: Computers, Windows Administration — Carl @ 12:17 pm

Dialog boxes that make you go hmm…

 

(From the Active Directory Replication Monitor)

Older Posts »

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.