Windows version of Postman, corporate proxy, and localhost

October 6, 2016

With the windows version of postman (not the chrome app version) and some corporate auto-proxy setups, requests to localhost may result in “Your requested host “localhost” could not be resolved by DNS.”

Which was a real head scratcher, and google let me down.

The solution is an environment variable
NO_PROXY = localhost

Thanks to some friends of friends, my 8 hours of cursing came to an end.


Chrome is silently killing your SSD

August 5, 2016

So I am the proud owner of new SSD drive to replace an old spinner in my laptop. Because I cloned my old windows install that used to be on a spinner, I have been keeping an eye on things and making sure windows is treating it as an SSD properly so I don’t end up with a dead drive sooner than I have to.

Right away I noticed some concerning I/O activity so I went and did things like kill the indexing service, etc hoping to see it come to an end. Nope, still seeing tons of writes.

I researched  further and used Sysinternals ProcessExplorer to discover that it is Chrome that is going to town with write operations.

Googling about that lead to some settings to turn off. The malicious website checking and prefetching settings were the problem according to Google. So I turned those off. I’m all set now right? Wrong! I left one process running for 6 hours, and it did 2 million writes for 2.5 GB of data.

Anyway, to end the story short, I now close all chrome instances before walking away from my laptop.


Interesting SqlException

March 8, 2013

Working with a ReST API that uses Linq to SQL for a DAL.

We have a method that calls a stored procedure that does various SQL statements and does it in a transaction that it either commits or rolls back.

If we called this method 5 times in a row, it would “hang” the api for subsequent calls that did multiple queries. Any call that traversed a relationship and queried the child table would throw this SQL exception:

The server failed to resume the transaction. Desc:#########

The proc that was called returns a table of errors (if any). Our API was never consuming this table.

Thanks to this blog entry, I was enlightened into the need to consume that return table.

Once I consumed the return table, the connections stopped being “stuck” with a transaction context.


Dedicated Administrator Connection on SQL Server Express 2008

September 14, 2012

Putting this here for future reference.
There are a number of things required to make a successful DAC connection on SQL Server express 2008:

1) add the trace flag(-T7806) to the startup parameters and restart the service.

2) Use “new database engine query” instead of “new query” or “connect”

3) Make sure the browser service is running

4) Stick “admin:” in front of the servername\instance when you connect.

References:

http://stackoverflow.com/questions/7670636/how-to-decrypt-stored-procedure-in-sql-server-2008

http://zarez.net/?p=883

http://chopeen.blogspot.com/2006/08/dedicated-administrator-connections-are.html


Lazy and Sloppy Developers

October 14, 2009

Developers, please think of the poor SOB that has to maintain your code 2 years after you leave the company. I just ran in to a block of code that did not make any sense. It read “if(includeBlahItems) {do something}” that obviously only runs if there are some Blah items right?. Wrong! In this code, the boolean value called “includeBlahItems” only gets set to true when there were NOT any BlahItems to deal with?!?!

Please don’t do that. Rename the variable, or set it to false when there are not any Blah items and change the if block to “if(!includeBlahItems) {do something}”.


The Small Business Restaurant Case Against Obama-care

July 21, 2009

This is a letter written by a friend of mine:

America – as a small business restaurant owner I’m appalled that very few (politically, media) are discussing the massive impact Obama-care will have on small businesses. We simply cannot afford mandated employer health care in our industry, and keep in mind that our industry is one of the most critical backbones of the entire American economy- there are over 945,000 restaurants in America, employing over 13 million people.

Keep in mind we primarily employ entry level and relatively unskilled laborers in the restaurant business. Our business models are built on razor thin margins as our customers (the American public) demand great value for their food- we simply cannot afford to provide health insurance for our majority unskilled and frequently transitory workforce – in many cases they are already paid higher wages than their skills could demand in an unregulated market via inflation indexed mandatory minimum wage laws. Mind you we do offer solid compensation and health benefits to management and senior staff who by virtue of their skills, responsibilities, achievements and longevity have earned them. We are already hammered by mandatory minimum wage increase that have siphoned off critical profits from our business in this time of recession- contributing greatly to significant price increases and labor force reductions already. Now Obama-care is proposing an 8% payroll surtax to finance mandatory health care?! This is INSANITY. Restaurants are built on after tax cash flow business models of less than 5% (which mind you has already been chipped by about 2% for min wage increases and price discounting to maintain traffic during a recession has hurt profits as well). Given payroll represents on average 25% of a restaurant business’s sales, an 8% surtax represent another 2 % hit to the bottom line! The senate version is almost as bad. And don’t let the small business exceptions fool you as restaurants are VERY labor intensive, and even a single small restaurant operation typically employees 20-30 people- practically every restaurant in America will be impacted by the mandate. Given that most small business restaurant operators survive on scale (2-10 locations) and again at very low margins, the small business exceptions will provide no relief for those in the restaurant industry who provide the majority of jobs.

What does the administration think businesses will do in reaction to this law? For starters we will be forced to drastically reduce staffing in an effort to reduce our payrolls and offset the tax impact on our profits- I anticipate the current hiring freezes in the industry to turn into massive layoff waves, and the industry to cut back dramatically to levels that will significantly impact our service models and even our ability to continue to operate. Second we will have no choice but to raise prices significantly- the HIDDEN TAX on the American public is that all taxes are ultimately passed on to the consumer. Third, and perhaps worse, many, many, MANY restaurants will simply not be able to cope with the cost burden and will fold almost overnight, swelling the ranks of the unemployed even more drastically. Finally, the financial incentive to build new restaurants in America will be gone. Say goodbye to new and interesting and convenient cuisine options in your neighborhood as no rational investor will put money in the future into a money losing business proposition.

Don’t pretend for a second that the administration doesn’t know this. Isn’t it convenient that they have planned the tax increases to be time delayed till 2011, hopeful that the American consumer will separate cause (Obama-care passes in 2009) from effect (massive unemployment waive in 2011)? Perhaps in the interim the unemployment numbers will trend up temporarily to mask his economically unsound strategies. I can assure you that come 2011 the economic consequences will be stunning to say the least.

Also, don’t be fooled by big businesses (Wal-mart, GE, etc) which have the scale and size to absorb these costs and are supporting Obama-care/similar measures. They see the law as a means to strangle their small business competition with regulations that will overwhelm and bankrupt them, freeing up market share for them to absorb. In fact, these big business bedfellows are counting on reduced competition from the small business sector to offset their losses on health care costs. Much like the big business-government collaboration of the past (railroad regulations) and the present (green initiatives trumpeted by Goldman Sachs and GE), their support is calculated and self-interested and in no way reflects the ability of the broader small business economy to absorb misguided policy.

Please put the word out to others that the consequences of this bill are far, far reaching and dire throughout the economy to consumers and businesses alike. Obama-care could kill the small-business economic goose that has laid golden eggs almost uninterrupted since the Reagan revolution. Do we really want 20% unemployment and small-businesses shuttered up all across America? Mandate business funding of employee health costs and you will see just that. And when small businesses are no longer here to foot the bill, guess who the government will come calling to NEXT to make up for the shortfall in funding? To quote Pastor Martin Niemöller:

“In Germany, they came first for the Communists, And I didn’t speak up because I wasn’t a Communist;
And then they came for the trade unionists, And I didn’t speak up because I wasn’t a trade unionist;
And then they came for the Jews, And I didn’t speak up because I wasn’t a Jew;
And then… they came for me… And by that time there was no one left to speak up.”

Wake up America, before it’s too late!

Shane
Phoenix, AZ


Book Review: Microsoft AJAX Library Essentials

December 31, 2008

Microsoft AJAX Library Essentials is a book intended for ASP.NET developers who want to dive into client side programming and take full advantage of the Microsoft AJAX Library.

The book opens up with a brief history of the internet, http, and html. This chapter serves as a refresher for web programming veterans, or valuable information for beginners. Also provided for beginners are instructions for setting up your programming environment so you will be able to follow and try out the example code.

Next you are taken on a whirlwind tour of HTML, CSS, JavaScript, and the DOM and see examples of handling AJAX requests using XMLHttpRequest. If you have ever done any AJAX on your own (without the use of a library or framework), you could easily skip this entire chapter, if you have not, it is a wonderful tutorial on what goes on behind the scenes, and you get to see the inner workings that the libraries and frameworks provide easier access to.

The book does a very nice job of explaining how OOP principles can be used in JavaScript. I consider myself only an intermediate level JavaScript programmer, and I was able to follow the books explanations of what Closures, Prototypes, and what “this” means in relation to context and scope. For me it was an eye opening look into the potential power of JavaScript, which I have not used for much more than rudimentary AJAX calls and client-side data validation.

The rest of the book serves as a reference complete with code examples of how the Microsoft AJAX Library acts as a framework to make everything it just taught you easier. It shows the namespaces and method names (that will be familiar to Microsoft developers) which you can use in your own javascript code.

All in all, it is a nice reference and guide to using the Microsoft AJAX Library.


Static SQL With Dynamic Where Clause

October 31, 2008

I’ve been using this sort of syntax for a couple of years now to write dynamic where clauses:

SELECT
Col1
FROM
dbo.Table
WHERE
@param IS NULL OR Col1 = @param

Recent application timeouts at my company have us investigating SQL queries for performance issues. One of the things I have discovered is that queries like that one are prone to performance problems. That query example on a table that has 6800 rows in it caused 3869 reads when a the column being compared has an index, and the parameter was not null (query returned 1 row in 253 ms).

For whatever reason, rewriting the query like this:
SELECT
Col1
FROM
dbo.Table
WHERE
(Col1 = @param AND @param IS NOT NULL) OR (@param IS NULL)

The query only causes 106 reads and returns the same single row in 33 ms. I don’t pretend to understand why the query that looks worse and has a more complicated execution plan performs better, but it does. I got the idea to try it from this article

The degree to which the syntax difference helps depends on how the table is indexed, and the column involved. Sometimes that syntax change makes no difference at all. The same article also showed me another trick that works even better for performance, but only works for non-nullable columns and is more complicated because you have to provide appropriate @min and @max values, which may be difficult depending on the data type and data itself:

SELECT
Col1
FROM
dbo.Table
WHERE
Col BETWEEN COALESCE(@param, @min) AND COALESCE(@param, @max)


Overriding Web Service URL in web.config for Referenced Class Library

October 23, 2008

I do this so rarely, that I always forget how to do it. Sometimes in a web application, you reference a class library that uses a web service. The web service is not directly added to the web application, so nothing is in the web.config to override, and since it is a class library versus a web application, you need to add a sectionGroup so you won’t throw the yellow screen of death due to an unknown section “applicationSetttings”.

<configSections>

<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
<section name="ErrorHandler.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</sectionGroup>

</configSections>
<applicationSettings>

<ErrorHandler.Properties.Settings>
<setting name="ErrorHandler_ErrorLoggingWebService_ErrorLoggingWebService"
serializeAs="String">
<value>http://localhost/errorloggingwebservice/errorloggingwebservice.asmx</value>
</setting>
</ErrorHandler.Properties.Settings>

</applicationSettings>

 

 

 

 

 

 

 


Report Viewer Auto-Sizing

June 6, 2007

I was searching for some information on the report viewer control, and accidentally stumbled upon something I always wanted, but could not seem to figure out.

A combination of 2 properties will have the control automatically size itself to fit the entire report:

 AsyncRendering=false SizeToReportContent=true

The AsyncRendering=false changes the rendering to be in-line instead of a frame, which for whatever reason is required for the SizeToReportContent to work.

A noteworthy side-effect of these settings, is that images that have the “sizing” property set to “AutoSize” do not render correctly. They get shifted and cut off. Changing the sizing to FitProportial cured the rendering problem for me. This was not a property I set myself, so AutoSize must be the default.