Huge Discounts on Mobiles, Books, Cameras, Computers etc: @Flipkart
Flipkart.com

Monday, December 14, 2015

CyanogenMod OTA update

So I updated my Samsung Galaxy Note 1 (N7000) to latest CyanogenMod 12.1 (Android 5.1.1) from Night Owl.



There is an app called 'OTA Updates' in my app drawer and it found a newer build. I did a download and phone rebooted in recovery mode. Now I have to manually install the download zip, but where the hell is it?


After digging thru the internet and trying various locations, finally found:
/storage/sdcard0/OTAUpdates/*.zip (eg: 20151211.zip)





Tuesday, October 13, 2015

Create multiple folders in a path at once

Ever wanted to recreate a path (folder structure) in one shot, without creating folder by folder?!

The easiest way to do this on Windows is:
1) Go to Run, type cmd
2) Command Prompt would open, there type following command
3) md <your_path>

eg: md folder1\folder2\folder3\folder4\folder5

All 5 folders (directories) will be created as per above structure with a single command! Isn't it cool!

For more info on above command type md /?

md is same as mkdir!



Tuesday, June 09, 2015

Configuring Apache Cordova/Ionic

I wanted to create an app which can possible run on multiple platforms and decided to try Apache Cordova (earlier known as PhoneGap). It wasn't an easy sail as I thought it would be, had to spend many days to get the build to work finally. Even tried the ionic framework, but wasn't any better as it uses Cordova underneath.

The main issue I faced was the following error while building:
Error: Please install Android target 22
Tried many suggestions found online, still no luck! I had Android API 22 installed as per the Android SDK manager.




Finally I was able to get things working by doing the following:


  • Install NodeJS (used Windows installer)
  • Unzip latest ANT (1.9.4) and set ANT_HOME env var
  • Unzip Oracle Open JDK (32-bit, as per Visual Studio 64-bit won't work) and set JAVA_HOME
  • Unzip android SDK and set ANDROID_HOME, ADT_HOME and ANDROID_SDK_ROOT
  • Add %ANDROID_HOME%\tools;%ANDROID_HOME%\platform-tools; to PATH
  • Add \;%JAVA_HOME%\bin;%ANT_HOME%\bin; to PATH
Also try recreating the project or remove/add platform if build was not working and created it before doing the above.

The next issue was trying to emulate the build output (apk).
WARNING : no emulator specified, defaulting to Default
Waiting for emulator...
emulator: ERROR: no search paths found in this AVD's configuration.
Weird, the AVD's config.ini file is malformed. Try re-creating it.

I went to the Android SDK Manager (type 'android' in the shell) and tried creating a new AVD manually using existing Device template for Nexus 6. Found that CPU/ABI is missing and I need to install that first!


and then later
ERROR : No emulator images (avds) found.
1. Download desired System Image by running: android.BAT sdk
2. Create an AVD by running: android.BAT avd
HINT: For a faster emulator, use an Intel System Image and install the HAXM device driver

I first tried the "Intel x86 Atom_64 System Image, but ran into errors!
WARNING : no emulator specified, defaulting to AVD_for_Nexus_6_by_Google
Waiting for emulator...
emulator: ERROR: x86_64 emulation currently requires hardware acceleration!
Please ensure Intel HAXM is properly installed and usable.
CPU acceleration status: HAX kernel module is not installed!

Finally ended up using the ARM system image and it works fine, though may be a little slow!


Monday, June 08, 2015

Windows 8.1 Pro on a USB Drive

Xubuntu and Kodi on i3 NUC was nice. But I often run into issues and is quite time consuming to get things straight (perhaps because I am not a Linux expert too!). Anyway, everything was configured, up and running with Xubuntu 14.10 and the new 15.04 release came and messed things up. The sound doesn't work after the upgrade, I see only a Dummy Output! Searching on forums, I see many people reporting this issue, but no solution than to downgrade. Also had some HDMI sync issue every time I start my home theater receiver (keep the NUC running 24x7) too and was getting tired of linux on NUC! Intel provide very few drivers for linux. So it was time to give Windows a try :-)

Usually windows is very easy to setup, but I had a major challenge! I don't have a hard disk and Windows doesn't support installing to USB drives (or even portable HDD connected via USB). Btw, if you want to create a bootable Windows installer on USB, use the rufus utility and the Windows install ISO. It is like the LiLi for windows :-)

Thanks to Google, found that there is a Windows to Go option, though officially supported only for Enterprise edition. You can get it to work for other editions using a utility called WinToUSB. Though it seemed to save the day, Windows 8.1 Pro was not booting up, it was stuck on the logo with the progress spinning for ever! Finally got it to work using the VHD (vs Legacy) option supported by WinToUSB while creating the usb installer.

Now I got Windows on my NUC and everything works quite well, especially with all the wonderful intel drivers! Kodi works quite well too (Note: use WASAPI instead of DirectSound for clean unadulterated sound)

Note: You need to activate the windows with a valid key


Clone your bootable usb drive in minutes!

I have an Intel i3 NUC which runs Xubuntu full install on a Sandisk Extreme 16GB USB 3.0 stick. It doesn't have a hard disk :-) Everything was working fine (mostly use it to share hdd, printer etc and also as a media player - Kodi/XMBC), until it ran out of space trying to upgrade from Ububtu 14.10 to 15.04. So I bought a new Sandisk Ultra Fit 64GB USB 3.0 and was finding it hard to setup everything from scratch and reconfigure/customize it. I wanted to give Kubuntu a try, but install failed as it was not able to partition the USB drive (don't remember, but I think I was able to boot and install Xubuntu into same drive). I didn't want to waste anymore time and just wanted to get things going quickly. Was looking for easy ways to clone and found this!

There is a command called dd and using it I could clone my usb disk and boot from the new one in about 10-15 minutes!

The syntax is as follows:
dd if=/dev/sdc of=/dev/sda
Make sure you give the whole device (sdc vs sdc1) and not a partition. Also double check the source and target device names (sda/sdb/sdc) before you start the command.

Couple of things to keep in mind:

  • Target has to be same size or larger than source. If larger you can resize partitions later
  • boot record will be copied only if you clone whole device vs a partition
  • You can use the UI (eg: Disks) or sudo fdisk -l to find out the device names
  • You can optimize transfer by setting block sizes, eg: sudo dd if=/dev/sdx of=/dev/sdy bs=8M

Source:

Target:

You can see that after the operation, I have the same partitions from the 16GB drive on my new 64GB one. To resize existing partition, I removed the swap, resized main (leaving some space for swap at the end) and then created swap at the end. This was done using GParted.


Hope it saves many hours or days of yours, have fun!

Thursday, April 16, 2015

Getting started with ElasticSearch

Elasticsearch is a search server based on Apache Lucene. It provides a distributed, multitenant-capable full-text search engine with a RESTful web interface and schema-free JSON documents. Elasticsearch is developed in Java and is released as open source under the terms of the Apache License. Elasticsearch is the second most popular enterprise search engine, at the time of this post.

Elasticsearch can be used to search all kinds of documents. It provides scalable search, has near real-time search, and supports multitenancy. Elasticsearch is distributed, which means that indices can be divided into shards and each shard can have zero or more replicas. Each node hosts one or more shards, and acts as a coordinator to delegate operations to the correct shard(s). Rebalancing and routing are done automatically. Notable users of Elasticsearch include Wikimedia, GitHub, Stack Exchange, Netflix, The Guardian etc

But Elasticsearch is not just for mega-corporations. It has enabled many startups like Datadog and Klout to prototype ideas and to turn them into scalable solutions. Elasticsearch can run on your laptop, or scale out to hundreds of servers and petabytes of data. No individual part of Elasticsearch is new or revolutionary. Full-text search has been done before, as have analytics systems and distributed databases. The revolution is the combination of these individually useful parts into a single, coherent, real-time application. It has a low barrier to entry for the new user, but can keep pace with you as your skills and needs grow.

You can find a very useful Getting Started Guide here:
http://www.elastic.co/guide/en/elasticsearch/guide/master/getting-started.html

If you are impatient, this You Tube Video helps you get started quickly: Getting started with ElasticSearch

Note: The syntax of the settings posted at 24:54 of the video doesn't work as there are some changes in version 1.5.1 I used. Refer this link for correct usage: Using Synonyms

I would suggest Sense plugin for Chrome to easily explore elastic search:
https://chrome.google.com/webstore/search/sense
https://www.found.no/foundation/Sense-Elasticsearch-interface/

Alternatives are RESTClient for firefox and Fiddler for pretty much any platform.

You can use the head plugin for Elasticsearch to monitor and manage the server,

You can find all the REST commands below for easy copy-paste if you want to follow the video and try hands-on.

Add Sample Data


POST /places/restaurant
{
    "name" : "Joes Italiana",
    "description": "Best pasta around",
    "address": {
        "street":"464 S Main St",
        "city":"Los Angeles",
        "state":"CA",
        "zip":"90013"
    },
    "location":[34.023954, -118.3927072],
    "tags":["italian","spaghetti","pasta"],
    "rating": "4.5"
}
    POST /places/restaurant
{
    "name" : "Jose's Taco Shop",
    "description": "Best Tacos in SoCal",
    "address": {
        "street":"950 Vine St",
        "city":"Los Angeles",
        "state":"CA",
        "zip":"90038"
    },
    "location":[34.088186, -118.326603],
    "tags":["mexican","tacos","burritos"],
    "rating": "4.0"
}
POST /places/restaurant
{
    "name" : "Berry's Burritos",
    "description": "Best Burritos in New York!",
    "address": {
        "street":"230 W 4th St",
        "city":"New York",
        "state":"NY",
        "zip":"10014"
    },
    "location":[40.7543385, -73.976313],
    "tags":["mexican","tacos","burritos"],
    "rating": "4.3"
}
POST /places/restaurant
{
    "name" : "Steve's Italian Restaurant",
    "description": "Great food, great atmosphere",
    "address": {
        "street":"46 W 46th St",
        "city":"New York",
        "state":"NY",
        "zip":"10036"
    },
    "location":[40.751624, -73.9783865],
    "tags":["italian","spaghetti","pasta"],
    "rating": "3.5"
}

Various forms of Search and Filter

POST /places/restaurant/_search
{
    "query":{
        "match_all": {}
    }
}
POST /places/restaurant/_search
{
    "query":{
        "query_string": {
           "query": "tacos"
        }
    }
}
POST /places/restaurant/_search
{
    "query":{
        "query_string": {
           "query": "tacos",
           "fields": ["tags"]
        }
    }
}
POST /places/restaurant/_search
{
    "query":{
        "query_string": {
           "query": "taco",
           "fields": ["name"]
        }
    }
}
POST /places/restaurant/_search
{
    "query": {
        "filtered": {
           "query": {
               "query_string": {
                   "query": "tacos",
                   "fields": ["tags"]
                }
           },
           "filter": {
               "range": {
                  "rating": {
                     "gte": 4.0
                  }
               }
           }
        }
    }
}
POST /places/restaurant/_search
{
    "query": {
        "filtered": {
           "filter": {
               "range": {
                  "rating": {
                     "gte": 4.0
                  }
               }
           }
        }
    }
}
 
POST /places/restaurant/_search
{
    "query": {
        "filtered": {
            "query": {
                "match": {
                   "address.state": "ny"
                }
            },
            "filter": {
               "range": {
                  "rating": {
                     "gte": 4.0
                  }
               }
           }
        }
    }
}

Clear Index

DELETE /places

Rebuild index with Synonym support

POST /places
{
"settings": {
"analysis": {
"filter": {
"synonym": {
"type": "synonym",
"synonyms_path": "synonyms.txt",
"ignore_case": "true"
}
},
"analyzer": {
"synonym": {
"tokenizer": "whitespace",
"filter": ["synonym"]
}
}
}
},
"mappings": {
"restaurant": {
"_all": {
"enabled": true
},
"properties": {
"address.state": {
"type": "string",
"analyzer": "synonym"
},
"location": {
"type": "geo_point"
}
}
}
}
}

Bulk Insert of Data 

POST /places/restaurant/_bulk
{"index":{}}
{ "name" : "Joes Italiana", "description": "Best pasta around", "address": { "street":"464 S Main St", "city":"Los Angeles", "state":"CA", "zip":"90013" }, "location":[34.023954, -118.3927072], "tags":["italian","spaghetti","pasta"], "rating": "4.5" }
{"index":{}}
{ "name" : "Jose's Taco Shop", "description": "Best Tacos in SoCal", "address": { "street":"950 Vine St", "city":"Los Angeles", "state":"CA", "zip":"90038" }, "location":[34.088186, -118.326603], "tags":["mexican","tacos","burritos"], "rating": "4.0" }
{"index":{}}
{ "name" : "Berry's Burritos", "description": "Best Burritos in New York!", "address": { "street":"230 W 4th St", "city":"New York", "state":"NY", "zip":"10014" }, "location":[40.7543385, -73.976313], "tags":["mexican","tacos","burritos"], "rating": "4.3" }
{"index":{}}
{ "name" : "Steve's Italian Restaurant", "description": "Great food, great atmosphere", "address": { "street":"46 W 46th St", "city":"New York", "state":"NY", "zip":"10036" }, "location":[40.751624, -73.9783865], "tags":["italian","spaghetti","pasta"], "rating": "3.5" }

Synoym Search 

POST /places/restaurant/_search
{
    "query": {
        "filtered": {
            "query": {
                "match": {
                   "address.state": "new york"
           
    }
            },
            "filter": {
               "range": {
                  "rating": {
                     "gte": 4.0
                  }
               }
           }
        }
    }
}

Geospatial Search

POST /places/restaurant/_search
{
    "query": {
        "filtered": {
            "filter": {
               "geo_distance": {
                  "distance": "100km",
                  "location": [40.7894537,-73.9481288]
               }
           }
        }
    }
}

POST /places/restaurant/_search
{
    "query": {
        "filtered": {
            "filter": {
                "bool": {
                    "must": [
                        {
                           "range": {
                              "rating": {
                                "gte":"4.0"
                              }
                           }
                        },
                        {
                            "geo_distance": {
                              "distance": "100km",
                              "location": [40.7894537,-73.9481288]
                            }
                        }  
                    ]
                }
           }
        }
    }
}

Getting just Count

POST /places/restaurant/_count
{
    "query":{
        "query_string": {
           "query": "tacos"
        }
    }
}

Paged Data

POST /places/restaurant/_search?size=1&from=0
{
    "query":{
        "query_string": {
           "query": "tacos"
        }
    }

Saturday, April 11, 2015

Dash Cam G1WH Firmware Update


A Dash Cam is an invaluable asset when you run into an accident, like your insurance. It can provide critical information on how an accident happened and who is at fault. Apart from that, it may also record interesting things from the road like UFOs and funny moments :-)

There is a huge array of dash cams in the market with varying price and features. G1WH is a cheap Chinese cam which surpasses many leading manufactures in video quality, at half price or even less.




You can find heaps of reviews and praises online on this model:
http://thewirecutter.com/reviews/best-dash-cam/
http://www.techmoan.com/blog/2013/12/16/g1w-the-cheapest-dash-cam-thats-worth-buying.html
https://dashcamtalk.com/g1w/

There are currently 3 versions of G1W and mine is G1WH. It uses an all black case (more discreet) and has slightly wider angle of view (140 vs 120). All are based on the popular Novatek NT96650 processor and the Aptina AR0330 CMOS sensor.

I was having some issues with this though. The build quality is ok, but not the best. The mount tend to become loose easily and cam may fall off on receiving quick jerks. Also it is not recording reliably (switches off automatically after some time) and this can be fixed by turning off Motion sensor and reducing the G-Sensor sensitivity to Low/Med. Some people also had recording issues with some Class 10 memory cards, so a Class 6 branded (Samsung/Kingston/Sandisk) micro SD card is best suited. Also be warned that there are many fakes in the market (eBay/Amazon). Better to buy from gearbest.com or banggood.com.

There are many firmware updates and custom firmware available for the G1WH model. The updates provides you more fixes and even new features like entering your license plate number to be stamped with date, higher bit rate etc.

Here is supposedly the newest firmware for G1WH. The default language is Polish, but you can change it via the menu.
http://reliabledownloads.org/file/05JxN
Credits: http://vat19.pl/pl/blog/informacje/15-Firmware.html

It adds the following features:
  • Increased recording bitrate files (such as DVRs DOD) 
  • Polish language menu 
  • Added function car plate (not present in older versions) 
  • More stable operation 

My cam came with Firmware version 2014.0509, in case you screw up you can revert to it here:
http://reliabledownloads.org/file/05Jxn

NOTE: After updating firmware the menu button was not working for me. Same happened even after reverting to above 2014.0509. If same happens click on the camera button on the top (next to power) and then click Menu.

These are the instructions to update the firmware:
1. Download the firmware file to your computer
2. Unzip the file
3. Format your memory card in your computer (or unit)
4. Copy the bin file to the root of your memory card
5. Change the name of the firmware you would like to flash to FWDM800H (required as the G1WH will not update with bin files with names other then this)
6. Put card into camera
7. Power camera on (make sure the camera is plugged in)
8. The camera will update automatically.  The screen will stay off but the status light will be on; it will take 30-60 seeconds
9. After updating, format the card.

NOTE: Remove the firmware (.bin) from the memory card you would like to use or it will flash every time you start!


Monday, February 16, 2015

Open Command Window Here


When you are doing some hardcore development you may have to run many things in different console (CMD/Command Prompt/DOS) windows. Usually the fastest way is to go to Run, type cmd + Enter and cd to the desired location. There is an even better option. You can open CMD and cd to a folder just by right clicking on the folder and selecting a menu item. The trick is to use Shift + Right Click. This will give you additional options, and one of them is "Open command window here" (Windows 7).



Another very useful tip is to add your most frequently opened folders to favorites so that you see them in the left top of explorer and can open with a single click.