Posts

Showing posts from 2010

Weimar Moment Coming

Tomorrow the FED will, in all its inglorious righteousness, decide whether to print either $500 Billion or $ 1 Trillion in new fiat money to purchase securities. There's already been agricultural and commodity inflation (Think "food") for the better part of 2010. This will now send prices through the roof. These idiots have absolutely NO EARTHLY IDEA what they're doing or what the consequences are. Sooner or later, our FED devalued greenback will filter down to the consumer. Ron Paul, where are you when I need you? You're the only guy with the guts to be willing to abolish the Federal Reserve. There is no such thing as a "free lunch". If you print money the way the Obama Administration has done (in addition to spending it foolishly), somebody is going to have to pay the Piper. We can't get these idiots out of office fast enough. UPDATE: As of Nov 3 2010 the FED has announced a new program where they'll print enough fiat money to purchas...

New Silverlight Article

I posted a new article on Silverlight at eggheadcafe.com . This covers the use of Rene Schulte’s WriteableBitmapEx offering to create Hopalong Fractals.

Don’t Forget.

Image
On September 11, 2001, fanatic Islamist extremists declared war on America. They are still out there . They are determined to kill Americans. The rationale is not important when you are dealing with maniacs. There is only one choice: Eliminate them, so that they can never do it again. ServicePeople: Your service to the United States is deeply appreciated. We owe you a deep debt of gratitude for your selfless dedication to protecting everything we believe in – freedom, liberty, and life. We won’t forget the sacrifices you and your families have made in defense of the American way. DON’T FORGET.

GUIDs

NOTE: There is a more complete article on eggheadcafe.com here .

Get File Length over http before you download it

This is one of those forum questions that you “think” you know the answer to, and then you’re proven wrong. User wants to download a file from a remote site but they do not want to proceed with the download if the file is larger than 10MB. Make sense, right? I said there was no way to do this without downloading the file. I was wrong. Here’s how he solved his own problem: static void Main(string[] args) { string completeUrl = "http://www.eggheadcafe.com/FileUpload/1145921998_ObjectDumper.zip"; WebClient obj = new WebClient(); Stream s = obj.OpenRead(completeUrl); Console.WriteLine( obj.ResponseHeaders["Content-Length"].ToString()); s.Close(); obj = null; Console.ReadLine(); } The above correctly reports the file size of 85,827 bytes without ever downloading the file! Somebody had a problem. Instead of giving up (or worse, taking my so-called “expert advice”) he thought  “outside the box” and found a solution. I call that outstanding! NOTE: At least one comm...

Don’t criticize – Be a Mentor

I tweeted this concept recently and got a very positive response. As developers, business owners, partners, and gurus of various breeds, we are constantly exposed to situations where things other people do just don’t seem to fit our personal paradigm. Sometimes, a natural reaction may be to put somebody down or make a sarcastic comment. Don’t do it. Environments like this create a situation where we can excel as developers, or we can turn them into a situation where we turn out to be a complete and total ass because of our behavior towards others. No matter what the situation is, you can catch more flies with honey than with vinegar. There is NEVER a situation where putting somebody down will further the effort – not in development, not in personal interactions, not in a group. Never . What you need to do is step back, hold your breath, and think. Then, hopefully, you can find the resources in your inner being to respond in a positive manner. The results, if you work on...

MongoDb NoRM MonoDevelop on Ubuntu Linux

  This weekend I spent some time setting up Ubuntu Desktop on my Oracle VirtualBox. I installed MonoDevelop, and MongoDb. I added an ASP.NET Web Application that uses the NoRM C# Driver, and after a little futzing (like changing the port on the MonoDevelop XPS web server) it built and ran great! Interestingly, it was a  Visual Studio 2010 solution, but MonoDevelop was able to open it anyway. All I had to do is remove some of the references that “didn’t belong”, and remove the targetFramework attribute from the web.config. Now that’s quite an accomplishment, since I am most definitely not a Linux guy. Kudos to the MonoDevelop guys. They’ve done a great job. And it just shows how portable MongoDb really is. Being able to build and run .NET applications and  even ASP.NET apps on Linux is a big plus.

LINQ THINK

The more I use LINQ, the more I run into legacy code that can easily be improved. The nice thing about LINQ is that it can make your code more elegant and easier to understand, as well as, in most cases, more efficient. Let’s take a simple  example. Here I’ve extracted some legacy code in the form of a method that tells you if a given string “Key” is present in a string array. First, the “OLD” way: //"OLD" way: static bool IsKeyInArray(string[] items, string key) { if (items == null) return false; if (items.Length < 1) return false; if (String.IsNullOrEmpty(key)) return false; foreach (string item in items) { if (item.Trim() == key) { return true; } } return false; } The obvious  thing to see here is that we have to iterate over the entire array. Now the new “LINQY” way: static bool IsKeyInArray2(string[] items, string key) { bool isInArray = false; if (items == null || items.Length <1 || String.IsNullOrEmpty( key)) return false; if (items.ToList().Contains(key...

Don’t Make Other Developers Test Your Code

Yep! I run into this all the time. Developers make changes and enhancements, and they think everything is fantastic. They push it up into source control, and go home for the night. But It’s not fantastic. They don’t have unit tests to prove their code. The next morning, the other developer(s) update the code, and it breaks. Then of course you get into the inevitable series of emails centering around “Hey – this doesn’t work!” Here’s the deal: If you make changes to source code, you better have tests in place to prove that it works, and have run them and seen that they work.  They don't "have to be" fancy unit tests (although that's preferable). They just have to prove that whatever you did works. Only then should you feel comfortable and confident that you can check in your code. Anything less is completely unacceptable. Please DO NOT make me test your code for you! Got it?

Lean up Windows 7 with Msconfig

Image
  Most people are blissfully unaware of all the absolute JUNK that gets run when Windows starts up, mostly due to registry entries installed by various programs, drivers, and what not. Much of this junk can be safely disabled. You can use Msconfig to do it. Here’s how: Hit the Windows Start button at the lower left side of your Taskbar. Click RUN, then enter “msconfig” and click OK. You’ll see four Tabs – the one you want is “Startup”. You can start disabling items by unchecking them. Some items will be automatically reinstalled on the next startup by windows or by necessary drivers. But you can disable a lot, and that means less memory usage and less resource-hogging. Here are the first two screens of mine:   You can see that I have most of it (from the first screen) and all of them (on the second screen) disabled, along with even more on the third screen (not shown). I could care less about Adobe Updater, Itunes, Zune and whatever. If I need to run Itun...

Developers: Monetize Your Content

Developers: Do you have a content-rich web site or blog? Eggheadcafe.com has been in business for over 10 years. With over 10 Million pageviews monthly (and historically as high as 20 Million) we have learned “how to do it” – from Adsense to custom advertising, we’ve tested and proven virtually every approach that’s available. We know what works, and what doesn’t work.We make money. If you have a website or blog with fresh technical content, consider a joint venture or an equity deal with us to monetize that content now! We are in a position to consider any potential deal, no matter how small or large. For details, email me at pbromberg at gmail dot com with some details in confidence.

Guess Which Countries Have Government-run Health Care

An  Investor's Business Daily article provided some interesting statistics from a survey by the United Nations International Health Organization (see citation at bottom): Percentage of men and women who survived a cancer five years after diagnosis: U.S.      65% England 46% Canada 42% Percentage of patients diagnosed with diabetes who received treatment within six months: U.S.       93% England 15% Canada 43% Percentage of seniors needing hip replacement who received it within six months: U.S.      90% England 15% Canada 43% Percentage referred to a medical specialist who see one within one month: U.S.       77% England  40% Canada  43% Number of MRI scanners (a prime diagnostic tool) per million people: U.S.      71 England 14 Canada 18 Percentage of seniors (65+), with low income, who say they are...

Install Windows Server 2008 R2 and Sharepoint 2010 on a VM

"Politicians and diapers should be changed frequently, and for the same reason." — Eça de Queirós (Portuguese writer) For a couple of months now I’ve tried to install Server 2008 R2 (which only comes in the 64-bit flavor) and Sharepoint2010 on a virtual machine so that I could conveniently study SharePoint without all the extra resources hogging my regular development box. The first thing you learn is that Windows 7 Virtual PC will not handle a 64-bit guest operating system, not even if It’s the x64 version installed on an x64 box. Drats, Microsoft! Then you learn that VMware is somewhat bloated in that it  installs a lot of extra driver-type baggage, so I gave up on that.  And, I still had issues installing Server 2008 R2 on that. Plus it’s not free, although I do know that they do have a “free” Player version, to their credit. And then you learn that “supposedly” you can trick Windows 7 x64 into accepting an installation of SharePoint 2010 – but the fixes a...

1932, Anybody?

Robert Reich, former Labor Secretary and known Liberal, writes on his blog, “The economy is still in the gravitational pull of the Great Recession. All the booster rockets for getting us beyond it are failing”. Looks like at least some Liberals are starting to “get it”. Home sales are down. (New home sales, the lowest in recorded history!) Retail sales are down, and factory orders suffered their biggest decline since March of last year. So what are we doing about it? "Less than nothing," says Reich on his blog. For the second time in two years, Arnold Schwarzenegger has ordered most state workers' pay cut to the federal minimum wage because lawmakers missed their deadline to fix the state's $19 billion budget deficit. The Legislature's failure to act has left the state without a spending plan as the new fiscal year begins. Other states are approaching this Greek-style debacle. Total nonfarm payroll employment declined by 125,000 in June....

Less is More Redux

In my short happy life as a developer, I’ve run into all kinds of development efforts that include frameworks, libraries, web sites, and much more. The one thing that stands out as an irritant to me is complexity. Specifically, unnecessary complexity. I’ve seen developers author entire library assemblies that provide wrapper utility methods consisting of calls to .NET BCL methods that take one line of code – methods that could have been called inline without even the need for the “helper” classes. I’ve seen frameworks that duplicate code that is already present in the .NET Framework, usually because the developer didn’t know they already existed (e.g., writing your own “connection pool” when the providers already expose a perfectly fine one). I’ve seen frameworks with layer upon layer of interfaces, base classes, derived classes and convoluted, multiple code paths that are inefficient and slow down execution because the developers kept building and building on top of something t...

Addicted to Oil

30 years ago, Brazil imported 80% of its oil. With a strong sense of purpose, Brazil invested heavily in bio-fuel technology and refocused its transportation energy towards a resource Brazil could manufacture internally—sugar based ethanol. Today, Brazil uses flexible fuel vehicles that can run on gas, ethanol, or any combination of the two. It still has a mandate to be 100% independent of oil in 2011. Yes, Brazil still drills for oil, and they still use it - plenty of it. But at least they've had a plan for upwards of 30 years now. We have virtually none by comparison. If the President had some guts and some vision (like Kennedy did when he said we'd put a man on the moon in the next 10 years) and said "We're getting off oil by 2021", could we do it? Of course we could. It would create huge numbers of jobs, and it would deny billions in revenue to foreign producers many of whom DO NOT LIKE AMERICANS.  But, there's no vision, and no guts. And it is not lik...

A Layman’s Explanation of The Derivatives Market and Crash

  This was passed on to me by a good friend, and I found the analogy so compelling that I decided to share it: Heidi is the proprietor of a bar in Detroit . She realizes that virtually all of her customers  are unemployed alcoholics and, as such, can no longer afford to patronize her bar. To solve this problem, she comes up with new marketing plan that allows her customers to drink now, but pay later. She keeps track of the drinks consumed on a ledger (thereby granting the customers loans). Word gets around about Heidi's "drink now, pay later" marketing strategy and, as a result, increasing numbers of customers flood into Heidi's bar. Soon she has the largest sales volume for any bar in Detroit. By providing her customers' freedom from immediate payment demands, Heidi gets no resistance when, at regular intervals, she substantially increases her prices for wine and beer, the most consumed beverages. Consequently, Heidi's gross sales volume increases ma...

Upgrading to WCF RIA Services v1.0 and Ria Services Toolkit

The kind folks on the Silverlight and RIA Services teams have come out with v1.0 of RIA Services. However, the instructions they provide can be a bit misleading as to “What does what”. Here’s the skinny: 1) You can download the Silverlight 4 Tools installer, dated 5/13/2010 here . This will uninstall previous interim versions of the SDK, runtime and RIA Services – you do not have to uninstall anything before running it. 2) However, the above WILL NOT refresh the RIA Services Toolkit. That you must uninstall first, and then run the new Toolkit installer, dated 5/14/2010, which is here . I like the Web Platform Installer, but you can never be absolutely sure what exactly you are getting with it because the installation process is much more opaque than using an MSI installer file. If you use the above two steps, you are pretty much guaranteed to be 100% up to date! And don’t forget – you can run the tools installer from a DOS prompt with the /x option to extract everything to th...

Club Med and the Lessons of History (or, What am I talking, Greek?)

GREEK CRISIS: A serious debt crisis in Greece has rattled global financial markets and raised worries about whether other countries will be able to repay their debts. LEHMAN REPLAY: Economists are worried that the Greek crisis, if not contained, could turn into a repeat of the cascading financial panic that occurred in the fall of 2008 after Lehman Brothers collapsed. DEBT RESCUE: European countries and the International Monetary Fund are racing to assemble a package of loans for Greece that will be sufficient to convince markets that the country will not default on its debt obligations. Concerns have already surfaced in Congress that the broad demands of the sovereign debt crisis will quickly exhaust the I.M.F.’s reserves and leave the United States, the fund’s largest shareholder, with the bill. Professor Nouriel Roubini, the New York-based academic who was one of the few to anticipate the scale of the US financial crisis, told a panel in California that the buildup of debt i...

Obscene Wealth – Myths About Capitalism

Recently I tweeted a quote from John Stossel (who was quoting Michael Medved): "If you believe that when the rich get richer, the poor get poorer, then you believe that creating wealth causes poverty, and you're an idiot" This is the old zero-sum fallacy, which ignores that when two people engage in free exchange, both gain -- or they wouldn't have traded. That’s the way business works. I received a number of responses to that tweet, mostly espousing the leftist concept that Capitalism is bad and somehow that the concept of getting wealthy is “obscene” and it seems to occur “at the expense of others”. When does wealth (or the creation of wealth) become "obscene"? Is there some measuring stick we can hold against it with a red line on it that says "Obscenity Level"? Or is it just somebody's subjective, biased jugement? Other responses seemed to focus on the "deductive argument" logic of the statement, completely ignoring the point (and...

Internet Explorer: Flash "1 item remaining" - Movie Not Loaded

Image
A couple of days ago I started having an issue where if I’d go to Youtube.com to look at a Flash movie, I’d get to see only a black screen in the movie area. A right – click on the movie and I’d see “Movie not loaded”. In addition, the browser status bar reports “1 item remaining” – basically meaning, “I’m waiting for this movie to load”. Of course, this never goes away. You might be tempted to uninstall the Flash plugin or try any number of fixes including changing your Internet Explorer security settings, among other "tricks". Don't do it. Try this first. Here’s how I fixed it: In Internet Explorer, choose “Tools / Internet Options”. In the Browsing History section, click the “Delete” button and you should see a dialog like the above. Note that I have checked the History and Temporary Internet files checkboxes. Click Delete at the bottom and that should fix it. If that doesn’t work, do it again but this time uncheck the “Preserve Favorite website data” Item and click D...

Fix Uninstall Issues with Visual Studio Versions

Have you ever installed a BETA or CTP or an RC build of some Microsoft product such as Visual Studio, and then been faced with the unhappy situation that it could not find the installation sources when you attempted to uninstall the product, or it just didn’t uninstall “cleanly” – leaving traces of Registry entries that prevented you from installing a later version? It’s certainly happened to me several times. But today I ran into a program called Perfect Uninstaller that, for $35, turned out to be one heck of a bargain. Perfect Uninstaller has three modes to completely and totally uninstall any program. It starts out using the regular Windows Installer, but it doesn’t stop there – even if the installer says “I can’t find the MSI source for this”, it doesn't give up like the Windows MSIEXEC installer would do -- it picks up all the Registry Entries by scanning the Registry, and then it picks up all file traces by scanning the filesystem. The result is a 100% complete and total un...

Session and Cache are By Reference

Recently a colleague remarked that if he got a List of some type out of the ASP.NET Cache, and changed an item, the Cache item would also change. That is correct. Session (InProc) , Cache and Application all return "live" references. A good writeup on this can be found by friend and fellow MVP Rick Strahl here: http://www.west-wind.com/Weblog/posts/1214.aspx If you do not want this behavior, you need to either delete the Session / Cache / Application object and replace it with what you want later, or store a clone by duplicating the object, doing your work on the original that you got out of Cache, then replacing the existing cached item with your clone that was not changed. for example: using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace CachebyRef { public class Person { public String FirstName { get; set; } public String LastName { get; set; } } p...

When Job Growth Is Not Job Growth

The Department of Labor just reported that in February, employment fell by fewer-than-expected 36,000 jobs with the unemployment rate steady at 9.7%. While we may hear the Obama Administration or Harry Reid trying to spin this as some sort of economic victory for their stimulus or otherwise trying to put the best face on the economy, this is in reality not very good news. Let us remember that job growth needs to be around 125,000 jobs gained per month just to keep up with US population growth. To make up the roughly 10 million jobs it would take to get us to an employment situation about where we were near the peak of the economy, we'd have to see job growth of 350,000 per month for four years straight. Such a scenario seems unlikely while we live under the umbrella of the Obama-Pelosi-Reid cartel. The Obama Administration has quintupled, in just one year, the deficits that took its predecessor Bush eight years to create. Looking at the current stagnation in employment, in large pa...

String.Empty vs “” vs String. IsNullOrEmpty

I was reading up on this recently and a couple of interesting points came to light: myString = “” creates a new instance of type String. myString = String.Empty does not. The key item is doing comparisons. Here’s some sample test code: class Program { static void Main(string[] args) { String myString = ""; long a, b, c, d, e, f; Console.WriteLine("Method 1..."); a = DateTime.Now.Ticks; for (int index = 0; index { bool isEmpty = myString == ""; } b = DateTime.Now.Ticks; Console.WriteLine("Method 2..."); c = DateTime.Now.Ticks; for (int index = 0; index { bool isEmpty = myString.Length == 0; } d = DateTime.Now.Ticks; Console.WriteLine("Method 3..."); e = DateTime.Now.Ticks; for (int index = 0; index { bool isEmpty = String.IsNullOrEmpty(myString); } f = DateTime.Now.Ticks; var Method1 = b - a; var Method2 = d - c; var Method3 = f - e; Console.WriteLine("Method 1: bool isEmpty = myString == \...

Crunch Time for Visual Studio 2010

Just a note to beta testers, MVPs and others who are “exercising” Visual Studio 2010 RC: This is the time to get your stuff in to Microsoft Connect (or other appropriate venues) – as quickly as possible . I’ve already submitted several issues (mostly minor ones) and I see that the C# Insiders listserv has been very active with discussions. The sooner you can identify an issue and give the appropriate dev team a heads –up so they can check it out, the better a product we’ll see at RTM release time. Visual Studio 2010 is going to be a really great product - and there is still time for us to help make it even better. Thanks!

SQL Server 2008 64-Bit vs 32-Bit Performance

I’ve got an x64 machine I do most of my “hard core” development work on, that I’m very happy with. I’m running Windows 7 Ultimate x64 and have had few problems. The box only has 4GB RAM, but I almost never hit the ceiling with that, no matter what the heck I do. But recently, we needed to do some work on a database that has some tables with close to 6 million rows, and I needed to build FullText catalogs for some of them. That’s where SQL Server 2008 x64 crapped out . I had memory consumption issues that caused me to have to hold the power button down for 4 seconds just to be able to “get out of Dodge” if you will -- several times too. Mouse didn’t work, machine was unresponsive, etc. – just building a FullText catalog on this big table. Now I don’t care about all the KB’s and suggested “Fixes” and all that. I haven’t got the time to futz with this crap. So I said, OK, let’s get rid of this sucker and see if the x86 version of SQL Server 2008 does better. So I did, and guess what...