Skip to main content

Posts

Showing posts from 2017

Learn Java to have Permanent Job or These 15 Languages

There are thousands of programming languages, but some are far more popular than others. When a company goes out to find new programming talent, they're looking for people familiar with the languages and systems they already use - even as newer languages like Apple Swift or Google Go start to make a splash. Here are the programming languages you should learn if you always want to have a job, as suggested by the popular TIOBE Index , the Redmonk Programming Language Rankings, and the annual Stack Overflow developer survey. Java C Python PHP Visual Basic Javascript R Go Ruby Groovy Objective-C Perl Pascal Delphi Object Pascal Swift MATLAB

Executing Shell Command From Java Program

Shell commands can be executed from within Java programs by using exec() method of Runtime class. See example below: try { Process process = Runtime.getRuntime().exec("your-command"); } catch (IOException e) { e.printStackTrace(); } Output of the executed command can also be read as Process proc = Runtime.getRuntime().exec("your-command"); BufferedReader stdInput = new BufferedReader(new      InputStreamReader(proc.getInputStream())); BufferedReader stdError = new BufferedReader(new      InputStreamReader(proc.getErrorStream())); System.out.println("Standard Output:\n"); String s = null; while ((s = stdInput.readLine()) != null) {     System.out.println(s); } System.out.println("Standard Error:\n"); while ((s = stdError.readLine()) != null) {     System.out.println(s); }

Private Methods In Interfaces In Java 9

Java SE 9 is nearing its release date. At this time we have a fair idea about new features in Java 9. One of the major enhancements is the introduction of Private Methods in Interfaces. Initially, it might be confusing to understand requirement of private methods in an Interface, but let's try to understand it step by step. Pre Java 8 Era In pre Java 8 era, Interfaces were only skeletons to define class structure. They were not allowed to have definition for any method. public interface DBManager{       String USER_NAME = "xyz";       String PASSWORD = "*********";       void save(Employee obj);       void save(Department obj); } This created a situation, where, if we had single behavior for a method, we had to repeat same piece of code in each implementing class. This resulted in lot of redundant code. Another solution was, to use Abstract Class instead of an Interface. This approach had its own obvious problems. Default Methods in Java

New Features of Java 9

Java 9 upgrade is almost ready. Early access builds are already out in the wild, with general availability expected in September 2017. Today we have a very clear picture of what to expect from Java 9 release. If Java 8 was a major release of lambdas, streams and API changes, then Java 9 is all about modules, jshell, and a collection of under the hood and API updates. Let take a quick look at some of the major features in Java 9. 1. Java 9 Module System One of the big changes of Java 9 is the Module System. Oracle Corp is going to introduce their Jigsaw Project. Project Jigsaw’s goal is to make Java modular and break the JRE to inter-operable components. Modular source code is the first out of 4 steps towards Jigsaw and will not change the actual structure of the JRE and JDK. The purpose of this step is to reorganize the JDK source code into modules, enhance the build system to compile modules, and enforce module boundaries at build time. Before Java SE 9 versions

What are variables in SASS?

Sass Variables allow you to define a value once and use it in multiple places. Variables begin with dollar signs and are set like CSS properties. You can change the value of the variable in one place, and all instances where it is used will be updated. When defining a variable we store in it a value, which often reoccur in the CSS like a palette color, a font stack or the whole specs for a cool box-shadow. Also, mostly the variables are defined at a fixed location, like top of the SASS file or in a dedicated separate file. This makes it easy to locate and change the values, instead of searching through the entire stylesheet. Below you can see a simple example, where variables are used to define font, color and shadow. SCSS file: $title -font: normal 24px/1.5 'Open Sans' , sans-serif; $title-color : #F44336; $box -shadow-bottom-only: 0 2px 1px 0 rgba(0, 0, 0, 0.2); h1.title { font: $title -font; color: $ title-color; } div.container { color: $ title-color; bac

Creating Dynamic CSS

While creating a SaaS (Software as a Service) software, a major goal is to allow users to have their own branding on the SaaS software. This specifically means, allowing the users to customize colors and images of the software. Whenever faced with this problem, we start hunting for 'dynamic CSS'. We look for options where we can set values in our CSS stylesheets like colors and image at run-time. However, native CSS technology does not support setting values dynamically. So we come across pre-compilers like SASS and LESS. These pre-compilers support features like variables and rules, but again they do not allow you to change these values at run-time. These pre-compilers are mostly meant to improve organization of your stylesheets and make them easy to maintain. A software that could allow us to set CSS values from database and reflect those changes in real time (of course without any website downtime or re-compilation) would be an ideal solution. This is where GrooveUI c

What is GrooveUI?

GrooveUI is a web service that allows you to easily convert your website into a white labelled offering. GrooveUI allows you to create and apply new website themes in real time. You can manage stylesheet and images of you website on the fly. GrooveUI helps you to convert your SaaS (Software as a Service) software into a white labelled software in minutes. GrooveUI is built over industry trusted SASS(Syntactically Awesome StyleSheets) stylesheets. You only have to upload your SASS files to GrooveUI CDN (not other files) and connect your website to retrieve compiled CSS files from GrooveUI CDN. GrooveUI extracts all the SASS variables from your files and gives you a nice UI to update their values. You can create multiple themes and specify different values for each SASS variable based on Theme. Themes are accessed by specifying 'theme' parameter in your website URL. You can also configure multiple domains and sub-domain and set default theme for each of them. In that case

SASS with GrooveUI

SASS stands for Syntactically Awesome StyleSheets. Sass is a CSS pre-processor with syntax advancements. Style sheets created in SASS syntax are processed by the SASS compiler, and turned into regular CSS style sheets. It allows you to easily manage complex CSS files by using variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly, particularly with the help of the Compass style library. One of the most powerful features of SASS is the use of variables. Example, instead of repeating the value of your sites primary color at multiple places, you could define a variable for primary color and then use that throughout your stylesheet. SASS compiler will replace the value of variable with actual value while generating CSS. One feature which is left wanting, is the ability to dynamically update these variables, say from database values. This is

Client based website branding

More than often we are faced with situation where we have to show our website in Client Branding.This may require showing different logo for each client, showing website in different color themes etc. One simple solution is to run separate instances of our website for each Client. This easily becomes a maintenance nightmare if all the clients are share the same code base. Also, in a SaaS based platform this might not be possible or even economical. Another solution is to use scripting techniques like Javascript or PHP to update our CSS code and image links at run time. Though this is feasible but it makes UI code dependent on server side teams which might not be very optimal. Also, it introduces a performance bottleneck. A new tool that I have come across is GrooveUI . It's an online tool that allows the users to easily create multiple themes for a website and show same website in different themes based on URL from which a website is being accessed. No code changes are

Microsoft Excel FV function in Java

FV, one of the financial functions, calculates the future value of an investment based on a constant interest rate. You can use FV with either periodic, constant payments, or a single lump sum payment. Syntax FV(rate,nper,pmt,[pv],[type]) The syntax has the following arguments: Rate :- Required. The interest rate per period. Nper :- Required. The total number of payment periods in an annuity. Pmt :- Required. The payment made each period; it cannot change over the life of the annuity. Typically, pmt contains principal and interest but no other fees or taxes. If pmt is omitted, you must include the pv argument. Pv :- Optional. The present value, or the lump-sum amount that a series of future payments is worth right now. If pv is omitted, it is assumed to be 0 (zero), and you must include the pmt argument. Type :- Optional. The number 0 or 1 and indicates when payments are due. If type is omitted, it is assumed to be 0.            0 -  At the end of the period    

Mircrosoft Excel PPMT function in Java

Basic Description The Excel PPMT function calculates the payment on the principal, during a specific period of a loan or investment that is paid in constant periodic payments, with a constant interest rate. The syntax of the function is: PPMT( rate, per, nper, pv, [fv], [type] ) Where the arguments are as follows: rate - The interest rate, per period. per - The period for which the payment on the principal is to be calculated (must be an integer between 1 and nper). nper - The number of periods over which the loan or investment is to be paid. pv - The present value of the loan / investment. [fv] - An optional argument that specifies the future value of the loan / investment, at the end of nper payments. If omitted, [fv] takes on the default value of 0. [type] - An optional argument that specifies whether the payment is made at the start or the end of the period.              The [type] argument can have the value 0 or 1, meaning:                    0   -   The payment i

Microsoft Excel IPMT function in Java

Basic Description The Excel IPMT function calculates the interest payment, during a specific period of a loan or investment that is paid in constant periodic payments, with a constant interest rate. The syntax of the function is: IPMT( rate, per, nper, pv, [fv], [type] ) Where the arguments are as follows: rate - The interest rate, per period. per - The period for which the interest payment is to be calculated (must be an integer between 1 and nper). nper - The number of periods over which the loan or investment is to be paid. pv - The present value of the loan / investment. [fv] - An optional argument that specifies the future value of the loan / investment, at the end of nper payments. If omitted, [fv] takes on the default value of 0. [type] - An optional argument that defines whether the payment is made at the start or the end of the period.             The [type] argument can have the value 0 or 1, meaning:             0 - The payment is made at the end of th

Microsoft Excel PMT function in Java

PMT, one of the financial functions, calculates the payment for a loan based on constant payments and a constant interest rate. Syntax: PMT(rate, nper, pv, [fv], [type]) The PMT function syntax has the following arguments: Rate:- Required. The interest rate for the loan. Nper:- Required. The total number of payments for the loan. Pv:- Required. The present value, or the total amount that a series of future payments is worth now; also known as the principal. Fv:- Optional. The future value, or a cash balance you want to attain after the last payment is made. If fv is omitted, it is assumed to be 0 (zero), that is, the future value of a loan is 0. Type:- Optional. The number 0 (zero) or 1 and indicates when payments are due. This can be represented in Java function as: static public double pmt ( double r , int nper , double pv , double fv , int type ) { double pmt = - r * ( pv * Math . pow ( 1 + r , nper ) + fv ) / (( 1