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 192.168.1.144.xip.io

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

Rails New Command Throws SSL_connect error

I just downloaded a fresh install of Ruby on Rails for Windows and when do a rails new projectName, I get an SSL_connect error! How do fix this?

Here’s the specific error that you will get:

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://rubygems.org/gems/rake-10.4.2.gem)
An error occurred while installing rake (10.4.2), and Bundler cannot continue.
Make sure that `gem install rake -v ‘10.4.2’` succeeds before bundling.

After doing a big of Googling, I found this site that had a working solution. You can read the details there or just get this file, and put it in the folder:

C:\RailsInstaller\Ruby2.0.0\lib\ruby\2.0.0\rubygems\ssl_certs

Or similar location, and try again.

?? Operator

If you use nullable types in C# (e.g., int?, double?, boolean?, etc.) you may be interested to know that C# has a special operator for handling what to do if a value is null. It is called the null-coalescing operator. It works like this . . .

int? x = null;
int y = x ?? -1;

If x is null, then the value on the right side of the ?? will be used; otherwise, it will use the value of x to assign to y in the example above.

So, you don’t need to do things like this anymore . . .

int y = (x == null) ? x : -1;

Neat huh?

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):

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Fusion
Add:
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!