Open Cricket – Search for any cricket match

Ask about any cricket matches:

Won by a team in a series: matches won by india in world cup in 2015
Lost by a team batting 2nd: matches lost by india against australia batting 2nd in odi
Won by a team chasing a target: matches won by south africa chasing 400 in odi
Played by a team in a year: matches played by australia in test in this year
Played by a team scoring a particular score: matches played by sri lanka scoring 600+ in test
Won by a team against a particular team: matches won by india against pakistan in world cup
Won by a team with specific wickets left: matches won by india with 10 wickets left in odi

Try it out, and post your feedback in the comments!

IntelliJ – Use Java 8 Lambda in Watches/Evaluate Expression while debugging

In Mac OS, IntelliJ uses the default Apple provided JDK 1.6 to run the IDE. Because of this nature, you cannot use Java 8 syntax such as Lambda in Watches, Evaluate Window etc., during debugging.

To fix this, run IntelliJ under Java 1.8. Right click IntelliJ in Applications, and “Show Package Contents”. Open “Contents/Info.plist” and set JDK version as 1.8 like this:

Open IntelliJ now, and you should be able to use Java 8 functionalities while debugging!

Cucumber/Capybara – Random Error – Circular dependency detected while autoloading constant

Randomly, the first test in our test suite used to fail with an error – “RuntimeError – Circular dependency detected while autoloading constant <Mode/Controller name>”

The reason is that Capybara loads your app in multithreaded environment by default. Some of your app code using require might not be thread safe. Hence use

in your environment test file, for eg. config/environments/test.rb.

This is fixed in Rails 4.2. But for versions before 4.2, use the fix above.

failed to reconnect to node – ElasticSearch log

If you see “failed to reconnect to node” in your Elasticsearch log and you have only one running node, you need to the set the value for network.publish_host to in /etc/elasticsearch/elasticsearch.yml

Open Cricket – New Metrics – Not Outs, Strike Rate, Average & More

Introducing the following metrics today in Open Cricket stats search engine:

* Not outs
* Individual score
* Strike rate
* Average
* Thirties
* Maiden Overs
* Best Bowling Figure
* Econ rate
* Bowling Average
* Bowling Strike rate

Few sample questions:

which player has the highest not outs in ipl

which player has the best individual score in ipl

who has the best strike rate in t20

who has the best average in odi in India

which player has the most maiden overs in world cup

who has the best bowling figure in test?

who has the best economy rate in this year

which csk player has the best bowling average in t20

Try it out or ask your **own** question.

Open Cricket – Get stats from a specific team

Now, you can search for a stat within a particular team.

which player has the most wickets in world cup?
which “(indian|sri lankan|csk|rcb)” player has the most runs?

which indian player has the most wickets in world cup?

which sri lankan player has the most runs in Asia in test?

which indian player has the most runs in world cup in 2015?

which csk player has the most runs in Chennai?

Try it out and provide your feedback below.

Elasticsearch Python Client – Commands

Connecting to a Elasticsearch server

1. Create an index:

You can use custom analyzers in your settings while creating an index.

2. Set mappings for a index and a type:

You can use mappings to define custom fields for the index.

3. Total number of documents in an index:

4. Delete all documents in an index of specific type without deleting its mapping:

5. Get count of documents in each type in an index:


In [14]:'opencricket', search_type='count', body='{ "facets": { "count_by_type": { "terms": { "field": "_type" } } } }')
{'_shards': {'total': 5, 'successful': 5, 'failed': 0},
'took': 233,
'facets': {'count_by_type': {'other': 0,
'total': 3228942,
'_type': 'terms',
'missing': 0,
'terms': [{'term': 'scores', 'count': 985211},
{'term': 'player_stats', 'count': 971777},
{'term': 'compare', 'count': 561225},
{'term': 'matches', 'count': 308937},
{'term': 'most_x', 'count': 262800},
{'term': 'player_dismissals', 'count': 84096},
{'term': 'partnerships', 'count': 28032},
{'term': 'matches_cond', 'count': 26864}]}},
'hits': {'total': 3228942, 'hits': [], 'max_score': 0.0},
'timed_out': False}


Send STDERR to a separate file in Rails production

By default, Rails writes both STDOUT and STDERR streams to “<environment>.log” file. Fox example, in production, the file production.log has the request log as well as any application errors. But it is helpful, if you can send the errors to a separate file, that you can watch for errors.

Though there are gems to do this, the easiest way is to use the broadcast method available in Rails logger. Create a file with the following content and place it in ‘initializers’ directory.

That should set it up.

Prevent ViewPager from taking the full screen

The ViewPager does not support wrap_content for layout_height attribute as it never have all its children loaded at the same time, and can therefore not get an appropriate size (the option would be to have a pager that changes size every time you have switched page).


for your viewpager element. You will see both ViewPager and your second layout (concluded_matches_layout, in this case) in the same screen as below:

ViewPager and Another Layout in Same Screen

References – and

Issues while migrating MySQL to Postgres database

Like everyone else, I started to see the disadvantages in MySQL. Lack of ACID support, no analytical functions, no strict ANSI SQL compliance, no full text search etc.,

Following are the things to take care when you have plans to migrate your data to Postgres from MySQL

  1. Column names with mixed lower and upper cases
  2. Limit Clause SYNTAX change
  3. DATE_FORMAT function
  4. Convert TINYINT(1) to BOOLEAN datatypes
  5. Division by 0
  6.  null value in column “<column_name>” violates not-null constraint
  7. PG::CharacterNotInRepertoire: ERROR:  invalid byte sequence for encoding “UTF8″: 0xe92042 (Sequel::DatabaseError)
  8. Escape single quotes – :%s/\\/’/g