Spread operator in JavaScript

I loved the new spread operator of javascript that came with ES6. Basically, it has three dots. You might be familiar with the varagrs in Java. However, it's more than varargs. Let me give you some examples- Let’s say you have a variable- and you wanna concatenate a and b . There is a function to … Continue reading Spread operator in JavaScript

Turbocharging Java With Parallel Array Sorting

JDK enhancement proposal 103 brings a new way of array sorting which uses the Fork/Join parallelism technique to provide sorting of arrays in parallel. This new feature is going to be added in the forthcoming Java 9 release. Currently, we have two sorting implementations, one sorts arrays and another sorts collections. These two implementations perform … Continue reading Turbocharging Java With Parallel Array Sorting

Removing items from ArrayList in java 8

As we know ArrayList implementation of List interface store elements in an Array under the hood. Removing elements from ArrayList is a bit costly which is the order of n^2. Let's say I have a list of integers and I wanna remove all the nonprime number from the list. Typically what we do is, use … Continue reading Removing items from ArrayList in java 8

Things to consider before diving into Java Programming Language

I would like to point out a few things first - Java has the largest ecosystem among all the languages. So it may take you some time to get used to it. Give it 2 years, and it will be worth the effort. ( Though this should be true for every programming language) If you … Continue reading Things to consider before diving into Java Programming Language

The magic word in Java : CAFEBABE

Java compiler compiles a Java Source code into bytecode and stores it in a .class file which is then get executed by JMV. Well, we all know this, but do you know that all Java classes start with a magic word called - CAFE BABE ? In case you're curious and interested to know why, bear … Continue reading The magic word in Java : CAFEBABE

How to change the brightness of LCD display from command line in Ubuntu

Open your terminal and type this - If you have multiple monitors, you will have output as - here, VGA1 and HDMI1 are your display. If you want to change the brightness of 'VGA1' type following The brightness ranges from 0.0 to 1.0 and 1.0 means full black.

long/double are not atomic in Java

So I have been reading a lot of texts lately. Java Concurrency in Practice was probably one of the best book written for concurrent programming in Java. Though this book is written prior to Java 7, but it is still valid and did an excellent job explaining all the fundamentals. While reading, I came across a … Continue reading long/double are not atomic in Java

Custom JSON Deserialization with Jackson

There are times when you want to take a control over the normal flow and you want to do things your own way. This quick tutorial will help to know how to take over control from Jackson json deserialization and write your own deserializer.

Why 1000 == 1000 returns false but 100 == 100 returns true in java?

This is probably one of the well discussed topic, but I found it interesting. if you run the following code- You will get - Here is the basic:  we know that , if two references point to the same object, they are equal in terms of ==. If two references point to different objects, they … Continue reading Why 1000 == 1000 returns false but 100 == 100 returns true in java?

New Integer/Long parse method in java 9

I have just got install the Java 9 early access release and started playing around. I know that, this not the major release and it is more  of a bug fix release with a few tiny features. However, I found two additional pares method for long/Integer - both Integer and Long have these two methods. … Continue reading New Integer/Long parse method in java 9

How to find out the number of processor your system has ?

How to read name of the files in some directory and join them using commas ?

Scala does optimize tail recursion at compile time

I just got wowed. Scala does optimize tail recursion at compile time, I didn't know that. Say I have the following countDown() method -- Run it, you will immediately get java.lang.StackOverflowError. The equivalent Scala code, however, would run just fine.

Java Stream API

I have been using Java Stream API massively these days. So I thought, why not write a short tutorial on it. So what is steam anyway? Don't be confused with InputStream or OutputStream of Java IO. Stream are complete different thing in Java 8. A stream basically represents a sequence of elements and provide a … Continue reading Java Stream API

How to drop all tables in postgresql

Execute following commands:- DROP SCHEMA public CASCADE; CREATE SCHEMA public; GRANT ALL ON SCHEMA public TO postgres; GRANT ALL ON SCHEMA public TO public; COMMENT ON SCHEMA public IS 'standard public schema'; it works like a charm. For details, please visit: http://stackoverflow.com/a/21247009/893197

Gradle to maven conversion and vice versa

How to convert maven to gradle The first thing is, you have to install gradle. Its easy. I know you can do it.  Go to the installing guide: http://www.gradle.org/docs/current/userguide/installation.html Now the second step is to run 'gradle init' in the directory containing the POM file. This will  convert the maven build to a gradle build … Continue reading Gradle to maven conversion and vice versa

How to read call logs programmatically from android

It’s fairly easy. You need add following uses-permission in android manifest to get call history programmatically. That’s all here. And then create an activity and layout. We need to query from ContentProvider. And for that I used CursorClassLoader. Read about CursorLoader from here:  http://developer.android.com/training/load-data-background/setup-loader.html   I want to load 4 properties and they are- phone … Continue reading How to read call logs programmatically from android

How the java code gets executed and performs better?

Please bear with my attempt to inform you a little regarding the execution of Java code.Java’s code is compiled into byte code, which Java’s virtual machine executes.  This output is an intermediate language (IL) that is neither human readable nor machine-executable. Only the virtual machine understands it.  To execute this output, the virtual machine uses … Continue reading How the java code gets executed and performs better?

Is it necessary to know everything about a programming language before starting to develop an application in it?

I want to build an application in Java that uses Swing, networking and databases (JDBC). However, the catch is that I donot know anything about these three fields. However, I do know some concepts of core java such as interfaces, inner classes, exceptions and debugging, collections, multithreading and I/O Streams. I want to know if … Continue reading Is it necessary to know everything about a programming language before starting to develop an application in it?

Let’s play deep sleep

Do you ever take a train, bus, or cab? Do you ever fall asleep? Do you regularly miss your bus stop? Well, sleeping kit is here to help! Enter your destination into the application. When your transport is near your stop, sleeping kit will sound an alarm to alert you. If you’re asleep, the alarm … Continue reading Let’s play deep sleep

Android Layout Property Initializer Plugin for IntelliJ IDEA

Well, the very first version of IntelliJ IDEA plugin that I wrote over the last two nights, is now available for public use. This is nothing big, just a little, doing for fun. Any feedback would be greatly appreciated. General instruction First, download it from here. Just install it as you normally install plugin. Go … Continue reading Android Layout Property Initializer Plugin for IntelliJ IDEA

The 3rd party tools that I use in my every android application

Ormlite for Android Well many of you love ORM (Object rational mapper). It’s just another cool orm tool simply works fine with android’s sqlite database. Link: http://ormlite.com/sqlite_java_android_orm.shtml RoboGuice Who didn’t hear of Dependency Injection these days? RoboGuice is a framework that brings the simplicity and ease of Dependency Injection to Android, using Google's own Guice … Continue reading The 3rd party tools that I use in my every android application

A great place to learn and mingle

The Java User Group Bangladesh (JUGBD) is now formed and successfully finished its 2nd meetup in last week. We are doing great, it’s not an exaggeration. For those who doesn’t know what is JUG, let me brief a little. Java User Groups (JUGs) are basically a group of enthusiastic people who loves java and develop … Continue reading A great place to learn and mingle

Android – Expandable TextView

There are so many thread in Stack overflow for expandable TextVeiw. The idea is, initially the TextView will show a small portion of a long text and when it is clicked, it will show the rest of the text. So here is the code that how I solved it. Using following class: And add following … Continue reading Android – Expandable TextView

How to Remove Duplicate Rows from a Table in SQL Server

Introduction It is obvious that if somehow duplicate rows get inserted into a table, it becomes a major issue to delete those duplicate rows. So this topic will help us to delete those duplicate rows from the specific table. Background I used some basic T-SQL (Transact-SQL*) code to accomplish the problem. So you don’t need … Continue reading How to Remove Duplicate Rows from a Table in SQL Server

Random Thoughts – Caffeine

I'm worried about my personal productivity these days. I am a person who used to spend (maybe waste) time doing random things, but still worried about personal productivity. There are people that the term personal productivity meant nothing to them at all. To be honest, I do not like them. I love those people who … Continue reading Random Thoughts – Caffeine

Programmers Freedom

There is no such thing as true freedom. This is probably a true realization. In my understanding, freedom means, minimizing the level of dependence. As a programmer, we used to think we have a true freedom in computer stuff, as it seems we can do whatever we want to do. It is true, in fact, … Continue reading Programmers Freedom

Java Installation in Ubuntu

Method 1 Step 1: download jdk from: http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html   Step 2 : go to downloaded folder using command line terminal : Step 3: install jdk * change the folder name according to extracted jdk folder name,   Step 4: open .bashrc Step 5: add following line end of the .bashrc file Save and close .bashrc … Continue reading Java Installation in Ubuntu

Executing Linux command from Java

You know Linux commands are always fun. We always play on terminals. How about executing from our favorite language java? Then you need following class Now you can execute any command using this class. For example- And output will in your console like: USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND root         … Continue reading Executing Linux command from Java

Check out Birds Puzzle on Google Play

I have got an android app named Birds Puzzle in the android market. It is a kid friendly image slide puzzle game for Android displaying a set of bird picture slides that you move into the correct order.   Instruction: in the very first window there is a menu, you have to press on new … Continue reading Check out Birds Puzzle on Google Play