MongoDB : Importing JSON Data using mongoimport

I tried to import around 15.4 GB of Tweet data, which was in JSON format, into MongoDB 4.0 on Windows (8 GB Memory) and it imported successfully. Below is the command for the import.

C:\>mongoimport –host localhost –port 27017 –collection TwitterHealthColl –db HealthDB –file “C:/tmp/HTA_noduplicates.json”

or

mongoimport /db:HealthDB /collection:TwitterHealthColl /file:”D:/DOWNLOADS/HTA_noduplicates.json”

2019-06-21T13:02:03.940+0530 [#######################.] HealthDB.TwitterHealthColl 14.8GB/15.4GB (96.2%)
2019-06-21T13:02:06.940+0530 [#######################.] HealthDB.TwitterHealthColl 14.9GB/15.4GB (96.9%)
2019-06-21T13:02:09.941+0530 [#######################.] HealthDB.TwitterHealthColl 15.0GB/15.4GB (97.4%)
2019-06-21T13:02:12.940+0530 [#######################.] HealthDB.TwitterHealthColl 15.0GB/15.4GB (97.4%)
2019-06-21T13:02:15.940+0530 [#######################.] HealthDB.TwitterHealthColl 15.1GB/15.4GB (98.0%)
2019-06-21T13:02:18.940+0530 [#######################.] HealthDB.TwitterHealthColl 15.2GB/15.4GB (98.7%)
2019-06-21T13:02:21.940+0530 [#######################.] HealthDB.TwitterHealthColl 15.3GB/15.4GB (99.4%)
2019-06-21T13:02:24.498+0530 [########################] HealthDB.TwitterHealthColl 15.4GB/15.4GB (100.0%)
2019-06-21T13:02:24.498+0530 imported 3783557 documents

HDD to Samsung 850 Evo 500 GB SSD Performance Jump

I have a Dell XPS 17 L702X laptop which is a Core i7 and supposed to be fast. I upgraded it to have 16 GB RAM. Still, the pain point was Disk I/O lag caused by HDD which came pre-installed. I decided to go for  a swap of existing HDD with the fast Samsung 850 Evo 500 GB SSD as C: Drive and kept second HDD D: Drive the same. The results are there to see ! The below 2 screenshots before and after the upgrade tell their story. Windows Start is snappier and apps are snappier too ! Now I am pleased !

Before 😦

CaptureHDD

Lowsy HDD R/W speeds !

CaptureSSD

A happy me with very good R / W Speeds !

Installing the “Wonderful” Package Control in Sublime Text 3 Editor when behind a proxy server

1) Open Sublime Text 3
2) Press CTRL + ` to bring up Console
3) Type the below Python script to install Package Control (script available at – https://packagecontrol.io/installation)

import urllib.request,os,hashlib;
h = ‘df21e130d211cfc94d9b0905775a7c0f’ + ‘1e3d39e33b79698005270310898eea76’;
pf = ‘Package Control.sublime-package’;
ipp = sublime.installed_packages_path();
urllib.request.install_opener( urllib.request.build_opener( urllib.request.ProxyHandler({“http”:”http://YOUR_PROXY_IP_HERE:8080″})) );
by = urllib.request.urlopen( ‘http://packagecontrol.io/’ + pf.replace(‘ ‘, ‘%20’)).read();
dh = hashlib.sha256(by).hexdigest();
print(‘Error validating download (got %s instead of %s), please try manual install’ % (dh, h)) if dh != h else open(os.path.join( ipp, pf), ‘wb’ ).write(by)

NOTE: Changes below in the above text for handling Package Control install from behind a proxy.

urllib.request.ProxyHandler({“http”:”http://YOUR_PROXY_IP_HERE:8080″})

Enjoy your Package control !!

SublimePackageControl

Java | Dynamically read a file from AppServer Path. when file is outside WAR or EAR.

This post illustrates a way to read any file (say a properties file, XML File, XSLT File,  or image file ) as an InputStream object when the file needs to exist outside of an Application Context. Say you have an application accessible via a URL http://localhost:8080/MyApp, whose context is /MyApp.

Typically, there will be a WAR file responsible for this context /MyApp (say MyApp.war). Now if you want to access a file which is outside this context, In Glassfish app server there is a docroot folder where your domain is. This docroot folder serves as alternate root for documents.

  • Just create a folder, say, “data” under the docroot folder of your Glassfish domain.
  • Place your properties, image, or XML file there, say, myFile.xml.

In your web application, this will be accessible as URL

http://localhost:8080/data/myFile.xml    (you can check this direct “GET” URL in browser when web app is running)

You can read this URL as inputstream with the following code snippet:

String baseStaticFilePath = “”;
StringBuffer requestUrl = request.getRequestURL();
String requestUri = request.getRequestURI();
String ctxPath = request.getContextPath();
String baseAppUrl = requestUrl.substring(0, requestUrl.length() – requestUri.length() + ctxPath.length()) + “/”;

// this will give the base Application URL as  http://localhost:8080/MyApp/

Now all we need to do is to subsitute the MyApp with the “data” folder .

baseStaticFilePath = baseAppUrl.replaceAll(“MyApp“,”data“);

String outlierFileName = baseStaticFilePath + “myFile.xml”;

InputStream inputStream = new StreamSource(new URL(outlierFileName).openStream());

And we have the myFile.xml as InputStream object from within the web application.
The added benefit of obtaining this file as InputStream object is that any subsequent changes to this file are dynamically picked up (on the fly) on next call which would not be same as reading a file using getResourceAsStream() which is more of static in nature and may require AppServer restart.

Python | Windows | Running PIP in PyCharm console with Proxy configuration.

We can configure PIP to use a proxy as shown in the screenshot when using it from within JetBrains PyCharm CE or Ultimate Edition. We need to set an environment variable:

SET HTTPS_PROXY=your.proxy.server:yourProxyServerPort and pip is ready to download and install packages !

or you can also issue:

pip –proxy proxyServer.com:8080 install pandas

to update PIP

python -m pip –proxy proxyServer.com:8080 install –upgrade pip

capturepipproxy

Great Infographic | Healthcare

http://www.datasciencecentral.com/profiles/blogs/smart-spenders-in-healthcare-great-infographic

Clonezilla Spin : External Hard disk to USB drive

2016-05-03 21.08.37

Taking Clonezilla for a new spin by Cloning an external hard drive  containing Ubuntu Linux 14.04 LTS to a USB drive.

The Ubuntu 14.04 LTS on external hard drive is NOT a fresh one but has all software and customizations in it.

In a nutshell, image will sum it.

[Edit] Cloning was successful and I am now running the cloned Ubuntu 14.04 LTS from external USB Drive !

 

 

Super Cool Numix Circle Theme for Ubuntu 14.04 LTS and 16.04 LTS

This article at ItsFOSS details step-by-step instructions on how to install the Super Cool Numix icon theme on Ubuntu 14.04 LTS and 16.04 Xenial Xerus LTS.

http://itsfoss.com/install-numix-ubuntu/

Commands wise:

  • sudo add-apt-repository ppa:numix/ppa
  •  sudo apt-get update
  •  sudo apt-get install numix-gtk-theme numix-icon-theme-circle
    If you want to install Numix wallpapers, use the command below:
  •  sudo apt-get install numix-wallpaper-*
    If you do not already have the Unity Tweak Tool from Software Center, then install it as below:
  •  sudo apt-get install unity-tweak-tool
    If using GNOME, then install Gnome Tweak Tool as shown below:
  •  sudo apt-get install gnome-tweak-tool

Apply the theme by selecting in the GNOME Tweak Tool and Voila !

Kazam_screenshot_00002

 

Installing Open JDK 1.8 on Ubuntu 14.04 LTS

OpenJDK Java 8 has been made into official Ubuntu repositories for 14.10 Utopic and higher. For Ubuntu 14.04, Ubuntu 12.04, and Linux Mint 17 users here’s how to install it from PPA.

  • sudo add-apt-repository ppa:openjdk-r/ppa
  • sudo apt-get update
  • sudo apt-get install openjdk-8-jdk

    You may have more than one version (like Open JDK 1.7 installed previously), so run this command below to set the default Java

  • sudo update-alternatives --config java

    And set default Java Compiler by running:

    sudo update-alternatives --config javac

Finally, check the java and javac version by running the commands below:

  • java -version  ,  javac -version

Remove HTML Tags from a text String using JSoup HTML Library

JSoup is a very swift , lightweight library, which can be used to remove HTML Tags from a string containing HTML Tag Data to get only the text.

Sample program and screenshot below illustrate its use.

JSoup HTML Library

JSoup HTML Library