Friday, September 19, 2014

Convert a property like file to a HashMap For Java with Regex in Python

I have a huge list of property like file. Now I need to convert this property like file to a HashMap in Java. Let's say my HashMap variable name is myHashMap. Recently I was playing with RegEx and Python. So I thought why not try to combine RegEx with Python to do this job! So, here's my solution.
NB: I've trimmed the property key and value.



To get the detail of the pattern go to RegEx101 and paste the below expression inside regular expression section.











AUTHOR:OBSCURE

Pagination With Oracle In JPA Native Query

Pagination in MySQL or PostgreSQL with limit is very easy. But Oracle doesn't support limit. So, in oracle generating paging query is a real trick.
Finally found a nice solution. With this piece of code generation pagination query is like charm. So have fun with this.














AUTHOR:OBSCURE

Thursday, October 31, 2013

Online avro phonetic typing - বাংলা


Press Ctrl+m to switch between English and avro-phonetic bangla typing.
Hit Space, Enter or Tab to transliterate.


AUTHOR: OBSCURE

Tuesday, October 22, 2013

Transfer big file with scp without blocking console and see progress

Problem statement:
  1. I must move a large file from one host to another, I used scp for it.
  2. But I need to use it without blocking console so that I can exit the terminal, so I should use nohup with scp and &.
  3. But I wanna see progress after some time. 
After searching solution for this I found the screen. To transfer file with scp without blocking console:
  • Step 1:
    execute this line to transfer file to remote host
    • This command will prompt for a password, give remoteHost's password.
  • Step 2:

Monday, October 7, 2013

Export and Import MySQL database from terminal

Below code will export MySQL database to a file and import it to another MySQL database from the file.


















AUTHOR: OBSCURE

Install and configure MySQL database for Cent-OS

Following are the command to install and configure MySQL in Cent-OS.



If the log-in and all other privileges is needed from ip-address other than the localhost following command needed to execute depending on what is needed:





AUTHOR: OBSCURE

Thursday, July 4, 2013

How to find duplicate values, and occurrences count in Oracle Database?

the easiest SQL query which will return the duplicate value and count for a given column is as follows:




















AUTHOR: OBSCURE

Tuesday, June 4, 2013

How to start a java program without the console in windows?

Write the following code in a "bat" file. Now double click on the batch file to run the jar.



PS: replace the path of jar with your desired jar path.

AUTHOR: OBSCURE

Monday, June 3, 2013

View PIDs and command lines of all running Java processes in Windows

The following line will shows PIDs of all running Java processes in cmd:


and to kill a process from windows cmd:




AUTHOR: OBSCURE

Sunday, June 2, 2013

Unicode characters are showing as question mark(?) instead of real value in nusoap webservice client.

Web service send correct unicode characters, but nusoap converts them to question mark(?). Solution is, adding the following lines after creating nusoap client



AUTHOR: OBSCURE

Saturday, December 22, 2012

Enable Hibernate in Ubuntu 12.04


In Ubuntu 12.04 and newer, hibernation has been disabled by default in policykit. To enable hibernation, you can follow official documentation here.

 Before enabling hibernation, please try to test whether it works correctly by running pm-hibernate in a terminal. The system will try to hibernate. If you are able to start the system again then you are more or less safe to add an override.

To do so, start editing:

sudo gedit /etc/polkit-1/localauthority/50-local.d/com.ubuntu.enable-hibernate.pkla


Paste the following lines:

[Re-enable hibernate by default]
Identity=unix-user:*
Action=org.freedesktop.upower.hibernate
ResultActive=yes

Save and exit gedit.

Restart and hibernation is back!

Or run the following code to just reset the menu:
killall unity-panel-service

Source: How to enable hibernation?

AUTHOR: OBSCURE

Wednesday, December 5, 2012

Serial Port Communication From Java - RxTx Installation.

Want to communicate with serial port using Java? You may want to try RxTx library. It's easy to use.
To install follow the instruction below:

The official RxTx binary pack is available here. The provided link will download the distro with some standard binaries (for linux 32bit, 64 bit, etc). If binaries for your specific operating system are not included, you may consider recompiling RxTx yourselves.
For a custom Win64 RxTx distro, have a look at the CloudHopper's web site.
To install it, unzip the distribution file in a temporary place and do the following copies:
  • File RXTXcomm.jar should go under JDKDIR/jre/lib/ext/
  • The necessary library( .so for linux, .dll for windows) should go under JDKDIR/jre/bin/
AUTHOR: OBSCURE

Sunday, December 2, 2012

Ambiguity problem in C++

Functions with predefined value can cause ambiguity in C++. See the example below:


If I call this like this, the first call is ok, but the second call give the ambiguous function error.




AUTHOR:
OBSCURE

Thursday, November 29, 2012

PYTHON REFERENCES

    1. Online Python Tutor : It is a free educational tool that helps students overcome a fundamental barrier to learning programming: understanding what happens as the computer executes each line of a program's source code. Using this tool, a teacher or student can write a Python program directly in the web browser and visualize what the computer is doing step-by-step as it executes the program.
    2. life is short - you need Python!: A blog on Python with tutorials, code, programs, tips and tricks, how-to, book-list, crawler / spider help, data structure and algorithm implementation and many more ... maintained by Tamim Shahriar Subeen, one of the best IT professional in Bangladesh.
    3. Python for fun - advanced python codes: This collection is a presentation of several small Python programs. They are aimed at intermediate programmers; people who have studied Python and are fairly comfortable with basic recursion and object oriented techniques. Each program is very short, never more than a couple of pages and accompanied with a write-up.
    4. site aims to be both a library of educational materials using Python to teach computer programming, and a virtual meeting place for teachers and students engaged in learning and teaching using Python.  Happy computing!