Surviving Windows 8 First Encounter

After installing Windows 8 you might quickly find yourself at unease at doing few things the old way or “cornering” the mouse too much. The answer to your frustration is keyboard shortcuts! There are many but below are the ones that would save the day:

Windows + D Jump to Desktop mode
Windows Switch between Start screen and last app
Windows + Q Search Apps
Windows + W Search Settings
Windows + X A popup menu for power users  (Command Prompt, Control Panel, File Explorer, Computer Management etc)
Alt + F4 Close app (Metro app doesn’t have close button)
Windows + E Open explorer
Windows + R The good old Run dialog
Windows + C Open Charms bar (allows you to quickly go to Settings and Search options for the app)
Page Up/Down Move around tiles on Start screen
Ctrl+Shift+Esc Task Manager
Windows + Tab Recent Metro apps
Right Click on Tile Options for uninstall, pin, unpin, size etc
Windows + Z or Right Click inside Metro App Show App specific bar (for example, open file, play button etc)
Windows + . Snap metro app on left

Viewing Venus Transit in Seattle Area

Well, bad news. Weather isn’t looking good for tomorrow’s historic event. It’s like 80% chance of showers almost entire Pacific Northwest extending even in to Eastern Washington. Even LIGO Observatory is not going to have sun shine. But if you believe that a hole in the sky might appear just to take pick then there are several events lined up for public viewing with free entry and no registration. Public events are much safer way to view Venus Transit because they would have appropriate solar filters and/or projection boards. Some might even have live webcasts. If that much anticipated hole in the sky does not appear then here are the options for online viewing:

It would be also good time to brush up on Venus peculiarities and some historical context.

Groups, Places and Collectives for Makers in Seattle Area

We went to Mini Makers Faire in Seattle today and one of most surprising thing I learned was how abundant are the local resources for hackers and makers! Reminded me of geek fairy tales of Homebrew Computer Club that you often hear. Here are some of the things you want to check out if you are interested in making stuff and live in Seattle area:

  • Metrix Create: Space – I think this was the coolest thing I came to know about. They have a shop with everything from sewing machine to electronics. They run lots of interesting workshops & classes. It’s your neighborhood fab lab!
  • Make Seattle Meetup Group – Regular meet ups for Arduino/electronics makers and learners to exchange ideas and get help on your projects
  • West Seattle Tools Library – I thought this was the coolest concept. They have a collection of 1500 tools that you can checkout for your projects. Just look at their tool of the week series. There is also Fixers Collective who meet up at Tools Library and would be happy to fix your broken stuff or just tinker around.
  • Xbot Robotics Workshop Space – They provide you space to work on your projects along with access to almost everything you need such as power tools, soldering stations, oscilloscopes, electronics components, drill presses, sand blasters, table saws, sanders, grinders!

There were quite a few of cool things we saw there everything from The Brain Machine, Zigduino, Lifesuit, Drawbots, to The Most Useless Machine Ever.

I also jotted down the next classes I want to do at Pratt and All Metal Arts.

BadImageFormatException - This assembly is built by a runtime newer than the currently loaded

Strange thing happened today. I upgraded one of the internal tool to .Net 4.0 without any issues but as soon as I attempt to debug/run the binary, I’ll see this exception:

System.BadImageFormatException was unhandled Message: Could not load file or assembly SomeTool.exe' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

Normally you see this exception if the machine doesn’t have right run time installed. But this was obviously not the case. Changing build to x86 or x64 didn’t made any difference either. Next I ran peverify.exe which happily reported that there was nothing wrong with the binary image. Finally I needed to pull out the big guns, ask fuslogvw, which would show me if there are any dependent assembly binding that was failing. But that also didn’t produce any boom sounds. So the last resort was to just meditate over the issue for few minutes. And that works. In a sign of enlightenment I saw app.config buried along with bunch of files and it had these lines:

    <?xml version="1.0"?> 
    <configuration> 
    <startup><supportedRuntime version="v2.0.50727"/></startup></configuration>

Aha! Apparently the app.config doesn’t get updated (may be because it was in TFS?) when VS did the 4.0 upgrade. As app.config didn’t had anything else, just deleting this file solved the issue. I do wonder how many people come across this gotcha.

Burning Man Tips for the First Timers

There is no substitute to reading official Survival Guide but it does leaves out many things. So instead of writing my detailed trip report I thought about all the mistakes I’d made and converting them to tips. Here it goes…

  1. Sun shelter (things that look like REI Alcove) is absolutely essential if you just have a camping tent. I would however not recommend REI Alcove itself because it broke after withstanding 3 days of sandstorms. Obviously you also need nice camping chair to go with it.
  2. Regular tent stacks are not very useful to secure tents on playa. I didn’t believed that and my tent almost came out in sandstorms. The correct way to secure tent in playa is using something called “rebars”. You need 4 rebars for a regular camping tent, each 3” long and 1/2” wide. You need another 4 or 6 for sun shelter. Stores like Home Depot would cut the metal rod for you in these sizes. Of course, you will need big hammer as well to stack them (they don’t have pointy end). Finally, it’s a hazard to leave other end of these rusty metal rods open so you must stick a tennis ball or empty bottles on end of the rod that is sticking out.
  3. Sandstorms! In 2009 there were 3 full days of sandstorms. If you never seen one then here’s how it works: About 20-60 foot tall wall of sand that comes at you at anywhere between 10 miles to 40 miles an hour. The visibility typically drops to 5ft to 50ft and you see brownish sand everywhere around you. This can last for up to 8 hours straight. It actually looks cool and as a matter of fact I intentionally spent lots of time inside sandstorm taking photos (note: Many SLRs are not dust proof). Even on severe storm days almost everyone continued their activities as if it was normal weather. But they were prepared. Here’s what you need to be prepared:
    • You have to have sun glasses with minimum open space around lenses. I had Tifosi Ventoux and they worked kind of OK. A retainer is also essential not to loose them (remember there are no shops to buy extra pair).
    • Mask for the nose and mouth. I used Buff bandana so I can pull it up all the way to sunglasses. Next time I would also be using this, this or this mask so I can be absolutely worry free about staying longer out in dust storms.
    • Hat with cord and visor. This will allow you to walk heads down while visor protects your face. I used this hat and it’s absolutely the best hat I’ve ever owned. Added advantage of this hat is that it’s veil can be put in the direction of wind.
  4. As a first timer I found that 4 nights provides a very good breadth and depth for the experience. The reason it’s perfect is because you have to carry less food and water, not worry too much about getting shower and you still get to see nearly everything that’s out there. I would strongly recommend against staying less than 3 nights.
  5. Make a stop at Reno at least for a night before heading towards Black Rock City. Besides mini-Las Vegas style environment, you can also visit REI, Walmart and Walgreens to get the gear, water, grocery and so on. Pepermill Resort is where I stayed overnight because it’s cheapest awesome hotel in Reno.
  6. A compass is very useful to have to get on the right street when coming back in the night far away from playa.
  7. If you have 3-season camping tent you are probably in trouble. These tents usually have mesh in the walls for ventilation and they have rain fly to protect against rain. This arrangement however is pretty useless to protect against sandstorms. On a typical stormy day I would get about half inch layer of sand inside my 3 season tent and I had to spend an hour every night cleaning things up. Make sure you have duct tapes and things to cover up. Everything outside tent should be tied to rebars so it doesn’t fly away with storms.
  8. Weather at burning man is 110F+. It’s normally not possible to sleep inside the tent after 10 AM. It’s not unusual to stay up until 3 AM. Nights are cold and you will need a fleece jacket. I’d 30 degree rated bag which was bit warmer but worked fine. BTW, try to bring sleeping bag liner to avoid it getting sweaty.
  9. As a first timer it might be hard to understand culture of gifts. For example, someone I don’t know at all would give me something and I would be confused if I should really take it. This can spoil the experience for the giver and the taker. Here’s how it works: If someone gives you a gift, take it with a smile without hesitation and give them a gift in return. It’s that simple. The only thing to remember is to bring bunch of gifts that you can easily carry around. Here are some of the examples of gifts: Custom stickers with your favorite quotes, necklaces, bead jewelry, things that glows, Trillion Dollars Notes, candies, custom printed postcards and so on. A single major mistake first timers make is not to bring gifts to give away.
  10. Bicycles would be your savior. If you can’t bring from home then rent or steal from Reno. BRC is really huge and you would be lucky if you could walk just one street a day. Most events that I was interested usually were many miles apart and it’s impossible to make it on time without bicycle. Besides you really don’t want to get tired after walking 10 miles just to attend couple of events.
  11. As soon as you enter gate you will be handed a map and booklet of events. The map is easy to understand because of it’s semi-circle streets. Any location is specified by using hand of clock and name of the street. The 6 o’clock is the center while 2 o’clock and 10 o’clock are two ends of semi-circle. The street names are different every year depending on the theme.
  12. There is NO assigned camping sites at Burning Man (except for theme camps). Normally all except outer two streets are occupied within first couple of days. When I arrived on Wednesday evening I decided to keep as much distance from outer road as possible because that’s where all the cars keep passing by. But I did not wanted to be too inside because the view of vast playa on the outer street is awesome. I also wanted to stay in middle so distance to get on any side is minimized. Always consider if your neighbors have enough space around their tent to put picnic table or chairs or grills or another car. The best space I found on Wednesday night was at 7:15 and Kinship.
  13. If someone asks you “which camp are you in?” then that usually means “what is the name of your camp?”. You can consult with your neighbor to decide on some name for group camp and put on the sign. You can also tell the location such as 7:15 & Kinship like other first timers do.
  14. The iPhone & AT&T did worked with full 4 bars at Black Rock City in 2009. It’s really really a good choice to turn it off and resist temptation to tweet/facebook for your entire stay.
  15. Here’s one of the most disgusting part of my Burning Man experience: The place I choose to camp was up-winds in the path of potty patties. That means every time wind blew even a little it would smell really really bad. It was horrible. Fortunately I came to my tent only to sleep when smell was gone. It’s really worth to make sure you avoid such smelly spaces.
  16. Don’t wear jeans at Burning Man! Many places that do not allow jeans believe that they are too “casual” for them but at Burning Man you don’t want to wear jeans because they would be too “formal”! I wore my normal jeans on first night and felt so out of place and formal that it was embarrassing. If you must wear jeans then take your old jeans, paint them or tear them or whatever. Shorts are semi-casual options at Burning Man.
  17. The list of events at Burning Man is overwhelming. You do not have to go crazy to attend as many events as possible and it’s best to chose no more than 3 events per day to attend. It’s good idea to reserve one day just sit back at your tent and look at vast playa in mild warm wind :).
  18. Cooking at Burning Man can get tricky because of sandstorms. I’d bought my camping stove which didn’t work out in storms. Fortunately more prepared folks did cooking in their camps and gave away lots of free food. I’d also bought some non-perishable stuff like bananas, milk powder, Sahale snacks, bars, chips and so on. One last option for food is to go back to town via bus or car but that might ruin your experience. Fortunately I did not had that option because I didn’t had car and I never found the bus. One good outcome was that I lost few pounds! Next time I might just buy or rent a grill because it work better in dust storms.
  19. I estimated 1.5 gallon of water per day per person and it worked out well for me.
  20. You can meet and greet your neighbors without feeling awkward. When you cook meal, offer some to them. Always have at least two gifts to give away to your two neighbors while departing. Example of gifts are some sketch you made while at Burning Man or other art work or a poem or your favorite book or some photo you took.
  21. Yes, you do need kitchen sink! You will need it to brush teeth, wash hands etc. It’s not OK to spill water with soap on playa floor but if your sink is small and soap biodegradable then you would be ok to collect water in it and then go to outer street to flung it away
  22. Most people do not shower at Burning Man (or so I think). There are few elaborate large camps that set up showers and some even offer them to others as well. But in general, don’t expect showers. Alternative is wet towel to wipe off of your body.
  23. Many camps on inner circle serves free drinks to anyone who wants but you need to bring your own cup. It helps a lot if you have a cup with lid.
  24. There is a place everybody refers to as “The Temple”. It’s located beyond The Man and many first timers would even miss it because they usually don’t go beyond The Man (it’s a LONG walk too). The Temple is truly sacred in many aspects without being connected to even the concept of religion. It’s humbling and even moving to spend a day at the temple. The Temple burns on next day after The Man burns and more spectacularly.
  25. Burning Man usually has 35,000+ people which causes 2 to 4 hours of traffic jams while leaving. While it’s fun to see the parade of every RV ever made, the time with least traffic to leave Burning Man is on Saturday night after The Man burns. But the flip side is that you will miss even more spectacular burn of The Temple which is on Sunday night. Another flip side of leaving on Saturday night is that you run huge risk of falling sleep while driving. When I left on Saturday night I saw at least 3 accidents on the way and so I decided to just pull over and sleep anyway. For my next time, I would be leaving on Monday late afternoon.

Finally here are pictures from my trip which hopefully would give some idea about what to expect.

Mountain Weather in Washington

Usual weather websites do not give you the forecast at a point but rather around some town/city which renders them pretty useless for mountains. Here are the collected links for mountain weather forecasts for Washington:

  1. Mount Rainier at Paradise Visitor Center
  2. Mount Rainier at Camp Muir
  3. North Cascades NP – Sahale Arm
  4. North Cascades NP – Sahale Arm TH
  5. north Cascades NP – Windy Pass
  6. North Cascades NP – Mount Pilchuck TH
  7. Mount St Helens – Windy Ridge
  8. Mount St Helens – Windy Ridge TH
  9. Mount Baker – Artist Point
  10. Mount Baker – Skyline Divide
  11. Mount Baker – Ptarmigan Ridge TH
  12. Enchantments
  13. Olympics – Hurricane Ridge
  14. Olympics – Hole in the Wall
  15. Olympics – Mamot Pass TH
  16. Oregon Coast – Nehalem Bay State Park
  17. Mount Hood – Timberline Lodge
  18. Mount Hood – Vista Ridge
  19. Snoqualmie Pass Corridor – Mount Si
  20. Snoqualmie Pass Corridor – Granite Mountain
  21. Snoqualmie Pass Corridor – Chair Peak/Snow Lake
  22. Salmon La Sac – Iron Peak TH
  23. Esmeralda Basin TH

A Day in SQL Tuning

Today I got in to some heavy weight TSQL tuning. This time the target was a legendary sproc that was taking 3 mins and now I’m about to call it a day when this giant SP is eating only 16 sec. Not excellent but not bad at this point. Here are some notes…

  • Apparently resetting identity using DBCC CHECKIDENT can be expensive operation if you are also deleting all items from the table. One way to reduce time is use TRUNCATE TABLE before DBCC CHECKIDENT.
  • I prefer table variables instead of temp tables but one place temp tables are required is if you have lots of data in them and want index!
  • Data Tuning Wizard would come out with zero suggestions on many occasions but it does not mean there are no significant optimizations possible. The best way to “guess” possible index is to have index for all columns used in join and use INCLUDE clause that has columns accessed in SELECT. This last thing does attracts even the least interested query plans to use the index :).
  • If you have temp tables, it’s usually better to create index after you have inserted data instead of before.
  • If you have complex sproc, SQL Server Profiler will spit out thousands of trace lines during the run. A quick way to pin point the SQL statements needing performance tuning is to use File > Save As to put the trace results in to a table. You can use then following query that immediately surfaces culprits. Notice that statements which run in WHILE loop might take less time individually but collectively their duration sum may be higher. Below query would reveal this culprits immediately.
        select SUBSTRING(TextData, 1, 4000), SUM(duration), COUNT(1)
        from [SavedTrace]
        group by SUBSTRING(TextData, 1, 4000)
        order by 2 desc

One of the big performance hits occur when you must process individual rows one at a time instead of in set. For instance, let’s say you have a table with a column that has comma delimited values. Now you want to split these values in each cell and create a new table which would have N rows for each row in original table – one for each spitted value. The Internet is littered with dozen ways to split strings in TSQL, some even uses CTEs (not a good idea because there are lots of gotchas like max recursion limit). So far the best way is to use SQL CLR with code like below. Its as fast as any native TSQL juggling, if not faster. However most important thing here is not SQL CLR but how you use this table valued function and here’s the secret: The best bang for the performance you would get is using CROSS APPLY (or OUTER APPLY) with table valued UDF.

    public partial class UtilityFunctions
    {
        [Microsoft.SqlServer.Server.SqlFunction(FillRowMethodName = "FillRow", TableDefinition="StringPart nvarchar(max)", 
            IsDeterministic=true, IsPrecise=true, SystemDataAccess=SystemDataAccessKind.None)]
        public static IEnumerable ClrSplitString(SqlString sqlStringToSplit, SqlChars delimiter, SqlBoolean removeEmptyEntries)
        {
            if (!string.IsNullOrEmpty(sqlStringToSplit.Value))
            {
                return sqlStringToSplit.Value.Split(delimiter.Value
                    , (StringSplitOptions)(removeEmptyEntries ?
                            StringSplitOptions.RemoveEmptyEntries : StringSplitOptions.None));
            }
            else
            {
                return null;
            }
        }

        public static void FillRow(object obj, out SqlString splittedString)
        {
            if (obj != null)
                splittedString = new SqlString((string)obj);
            else
                splittedString = SqlString.Null;
        }
    }

Test Results Windows and Exception has been thrown by the target of an invocation

Just a note… if you are getting "Exception has been thrown by the target of an invocation" message when opening Test Results window in Visual Studio 2008 then it’s most likely because you have an open solution in offline mode that was bound to some TFS instance. A bug that can waste lots of your time if you didn’t knew about it!

What to do on dreaded error CS0003: Out of memory

I’ve spent way too much of time today (again!) on this error so here’s blog post for future reminder to me!

If you are generating or working with very large proxies then you might see following error:

Exception: InvalidOperationException
Message: Unable to generate a temporary class (result=1). error CS0001: Internal compiler error (0xc00000fd) error CS0003: Out of memory

This error typically occurs when .Net infrastructure attempts to generate *XmlSerializers.dll on the fly. To do this csc.exe is spawned off and if your proxy is too large then it might error out with a message like above. This seems to be a bug in csc and reportedly it might get fixed in .Net 4.0.

Meanwhile, here’s how you can workaround it:

First make sure all your classes that are derived from SoapHttpClientProtocol (i.e. the proxy classes) are decorated with WebServiceBindingAttribute. If you have a whole class hierarchy that derives from SoapHttpClientProtocol then all classes in that hierarchy must be decorated.

Next, for all the projects that contains classes derived from SoapHttpClientProtocol, turn “Generate serialization assembly” option on Build page to ON. Remember you will need to do this for Debug as well as Release mode or your code will fail in production.

Visual Studio XML Serialization Option

Now you are set. The *XmlSerializers.dll will be generated and signed+versioned automatically (if your project is signed and versioned) when you do build and csc.exe won’t get spawned to cause above error.

Few more things to keep in mind:

  • One of the “popular” workaround in some forums is to switch IIS app pool for WCF to 32-bit. I wouldn’t advise this because you loose all the advantage of 64-bit, primarily, access to all the memory available on server.
  • Above error often occurs for Microsoft Dynamics CRM proxies if you have tons of entities and attributes.
  • If your code is running as plugin then you might have plugin DLLs hosted at different location than main app exe. An example of this is Microsoft Dynamics CRM plugins that gets hosted by CRM Async service. In this case, you need to copy the *XmlSerializer.dll generated after the build to same location as host exe otherwise it won’t be found by .Net infrastructure!
  • If you are using Visual Studio integrated debugging feature for WCF services then you must run Visual Studio as Administrator or above error will pop its ugly head when you are debugging.

If above steps doesn’t solve your problem then you might have to dig deeper using techniques described here, watching binding errors from fuslogvw or attempt to generate Xml serilizer DLL manually using sgen.