Elasticsearch and Curl

When I use the curl commands for my Elasticsearch, it outputs a bunch of garbage and messes up the output of the command. How can I turn that off?

The problem is that the curl command itself is emitting information into the stdout stream.

You can turn that off on a command-by-command basis by just adding a –silent flag on the command like this:

 curl 'localhost:9200/_cat/indices?v' --silent

or, if you’re on a bash like shell (e.g., MINGW64 on windows), you can do this to not have to think about it anymore:

alias 'curl'='curl -s'

Thanks to this post on stackoverflow for the solution above.

Quick DNS

Here’s a quick and easy way to get a domain name to resolve to an IP.

Type in the IP address and follow it with an .xip.io like this:

$ ping

Pinging [] with 32 bytes of data:
Reply from bytes=32 time<1ms TTL=128
Reply from bytes=32 time<1ms TTL=128

Conflicting Assemblies

In Visual Studio, when compiling solutions, you may encounter the following error message:

Found conflicts between different versions of the same dependent assembly. Please set the “AutoGenerateBindingRedirects” property to true in the project file. For more information, see http://go.microsoft.com/fwlink/?LinkId=294190.

Or you might see a similar version of this when trying to browse to an ASP.NET website that looks like:

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

To see exactly the path and the assemblies that are causing the problem, you’ll need to turn on logging for the .NET binding process. The information above in the error message is not sufficient to enable this though. Here’s the full information needed in order to see the assembly binding (from Stackoverflow):

DWORD ForceLog set value to 1
DWORD LogFailures set value to 1
DWORD LogResourceBinds set value to 1
String LogPath set value to folder for logs (e.g. C:\FusionLog\)

Make sure you have that trailing backslash in the log path.

Then, restart your application or build and inspect the details in the log file or the output from ASP.Net!

Defaults in C# 4.0 Method Parameters

C# 4.0 was released in April 11, 2010. By that point, C# was 8 years old and there were A LOT of developers out there that knew C# already and didn’t pay much attention to the changes and didn’t incorporate them into their current code. Many were able to keep chugging along happily doing what they had been doing without having to learn about the new features.

That’s too bad.

One of my favorite, 4.0 additions is named-arguments and optional-parameters. I think they are my favorites because of my stint as a Visual Basic programmer during my time between PowerBuilder and C#. You got used to not supplying parameters if you didn’t care to pass them or didn’t need them.

You can easily tell when a developer doesn’t know about this feature too. They tend to have a lot of overloading of a method that essentially hides parameters. And, they make calls to variants of the methods when they want to have defaults and not supply them. Or, they don’t want to have to supply them everywhere.

Their code will look something like this:

public void Broadcast(string group, int unitId) { . . . }

public void Broadcast(string group) { Broadcast(group, 5); }

public void Broadcast() { Broadcast(“Red Leader”); }

From above, you can see that the first method takes two parameters. If this were the only method, you’d have to supply defaults everywhere. So, in the event that you just want to pass the group and always default to 5 in the unitId when you do, you could just call the second routine. Or, if you want to default both parameters, you could call the third variation, which calls the second, which then calls the first. That’s a lot of pushing and popping on the stack just to have defaults.

After C# 4.0, these three methods can be collapsed into just this one method by simply using defaults. Here’s what it looks like

public class Broadcaster
    public static void Broadcast(string group = "Red Leader",
       int unitId = 5) { Console.WriteLine("This is {0} {1}", group, unitId); } } class Program { static void Main(string[] args) { Broadcaster.Broadcast(); Broadcaster.Broadcast(group: "Blue Leader"); Broadcaster.Broadcast(unitId: 2); } }

So, if you just wanted to supply a different unitId, you simply pass in a unitId: 6 in the method call. The group would default, and the effect is as if you called the method with the parameters “Red Leader” and 5.

Defaults make these sorts of libraries much leaner to write.

I hope this helps you.

&nbsp; in XSLT

How can I use &nbsp; in my XSLT file?

Put this right below the XML declaration
<!DOCTYPE xsl:stylesheet [<!ENTITY nbsp "<xsl:text disable-output-escaping=’yes’>&amp;nbsp;</xsl:text>">]>
then, you can type &nbsp; in the document without any problems.

DW20.exe is Using 100% CPU

A process named DW20.exe is using 100% of my CPU on my web server and I can’t figure out what is causing it?

This is Microsoft’s error reporting tool (Dr. Watson). If you need to fix the problem immediately, feel free to kill the process when it appears. Your web server will start functioning fine after the process is dead.

In the long run, you can turn it off by following the instructions found here and just turning it off instead of on. By default, it is turned on.