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.

Earlier:
which player has the most wickets in world cup?
Now:
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:

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

3. Total number of documents in an index:

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

Use:

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 – http://stackoverflow.com/questions/8532307/android-viewpager-dimension and http://stackoverflow.com/q/13966904/184184

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

Ignore/Disable Crashlytics reports during App Development

In your ApplicationController (or the class that extends Application),

@Override
public void onCreate() {
Crashlytics crashlytics = new Crashlytics.Builder().disabled(BuildConfig.DEBUG).build();
Fabric.with(this, crashlytics);
}

Gradle will generate the appropriate value for BuildConfig.DEBUG based on your current build.

Editing /etc/hosts file in Genymotion Emulator

I use my local Rails app while developing the Android app. When I tried to connect “http://localhost:3000″ using Volley from the Android app that runs under Genymotion, it threw timeout error. It is because Genymotion runs under Virtualbox and Mac is it’s host OS. To get the IP of your host machine:

☁ duggout [master] ⚡ ifconfig vboxnet0
vboxnet0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> mtu 1500
ether 0a:00:27:00:00:00
inet 192.168.56.1 netmask 0xffffff00 broadcast 192.168.56.255

Now you can use “http://192.168.56.1:3000″ in your Android app to connect to the localhost of your host OS.

If you need to work with subdomains (mostly required for API driven applications) where your application requires the URL to be of the form “http://api.example.com”, you need to edit the hosts file of the virtualbox OS.

Connect your Genymotion device with adb.

./adb devices

to see your Genymotion device. If you do not see your device, open Genymotion settings, goto ADB tab, choose your ADB location instead of the default ADB provided by Genymotion. Restart emulator.

Create a new file (/tmp/hosts) in your system with the following contents:

192.168.56.1 localhost api.localhost.com

Now you need to push this file to the Genymotion Virtualbox OS using adb.

./adb root

./adb remount

./adb push /tmp/hosts /system/etc/

Restart emulator. Now you can connect using both localhost and api.localhost.com from your Android code.

Include JST EJS Partials in Rails Backbone

Template File

Partial file

Final Output when you render the template:

Refer this issue in GitHub.

Verify Discourse with Google Webmaster with HTML File Upload method

My DuggOut Forum is hosted on a subdomain. Though I have verified the parent domain (duggout.com) with Google Webmaster already, it still asked me to verify this subdomain.

Since all the other methods (Google Analytics, CNAME, TXT record, meta tag) failed, I had to go with HTML file upload based verification.

1. SSH into your host machine

2. SSH into the docker container

cd /var/discourse (or wherever discourse is installed)

./launcher ssh app

3. Create the Google provided HTML file under /var/www/discourse/public directory

Now, go and hit the URL –

http://forum.yoursite.com/google-verification-****.html

You will see it working and your Webmaster verification is complete.

One potential issue with this approach is that, whenever you upgrade your Discourse, the verification file gets deleted. You might want to wrap the above commands in a script that you can run after your Discourse upgrade.