Tutorial by Examples

Define Interface public interface ClickHandler { public void onButtonClick(User user); } Create Model class public class User { private String name; public User(String name) { this.name = name; } public String getName() { return name; } ...
With this example, you will be able to perform following operations: Connect to Firebase Storage Create a directory named “images” Upload a file in images directory Download a file from images directory Delete a file from images directory public class MainActivity extends AppCompatActivity...
Thanks to type-inference and partial application in F# data-driven programming is succinct and readable. Let's imagine we are selling car insurance. Before we try selling it to a customer, we try to determine if the customer is a valid potential customer for our company by checking the customer's ...
private boolean unpackZip(String path, String zipname){ InputStream is; ZipInputStream zis; try { String filename; is = new FileInputStream(path + zipname); zis = new ZipInputStream(new BufferedInputStream(is)); ZipEntry ze; byte[] buffer = new...
If you want to migrate from existing log4j 1.x in your project to log4j 2.x then remove all existing log4j 1.x dependencies and add the following dependency: Log4j 1.x API Bridge Maven Build <dependencies> <dependency> <groupId>org.apache.logging.log4j</groupId> ...
Starting from a dataframe df: U L 111 en 112 en 112 es 113 es 113 ja 113 zh 114 es Imagine you want to add a new column called S taking values from the following dictionary: d = {112: 'en', 113: 'es', 114: 'es', 111: 'en'} You can use map to perform a lookup on keys returni...
For accessing the MS SQL Server database Sqoop requires an additional JDBC driver which can be downloaded from Microsoft. The following steps will install MSSQL Server JDBC driver to Sqoop: wget 'http://download.microsoft.com/download/0/2/A/02AAE597-3865-456C-AE7F-613F99F850A8/sqljdbc_4.0.2206.100_...
To check that the connection to the server is valid: sqoop list-tables --connect "jdbc:sqlserver://<server_ip>:1433;database=<database_name>" --username <user_name> --password <password> Before doing this it is recommended ...
To import data from SQL Server to Hadoop: sqoop import --table TestTable --connect "jdbc:sqlserver://192.168.1.100:1433;database=Test_db" --username user --password password --split-by id --target-dir /user/test ...
Query can be used instead of table in import operation: sqoop import --query 'select Id,Message from TestTable where $CONDITIONS' --where 'id>100' --connect "jdbc:sqlserver://192.168.1.100:1433;database=Test_db --username user -–pas...
The data can be imported directly into Hive: sqoop import --hive-import --table EventLog --connect "jdbc:sqlserver://192.168.1.99:1433;database=Test_db" --username user --password password --split-by id ...
It is sometimes useful to create random Strings, maybe as Session-ID for a web-service or an initial password after registration for an application. This can be easily achieved using Streams. First we need to initialize a random number generator. To enhance security for the generated Strings, it i...
PhantomJS is a fully featured headless web browser with JavaScript support. Before you start you will need to download a PhantomJS driver, and make sure to put this in the beginning of your code: using OpenQA.Selenium; using OpenQA.Selenium.PhantomJS; Great, now onto the initialization: var d...
SimpleBrowser is a lightweight WebDriver without JavaScript support. It is considerably faster than an aforementioned PhantomJS, however when it comes to functionality, it is limited to simple tasks with no fancy features. Firstly, you will need to download the SimpleBrowser.WebDriver package and ...
Streams, and especially IntStreams, are an elegant way of implementing summation terms (∑). The ranges of the Stream can be used as the bounds of the summation. E.g., Madhava's approximation of Pi is given by the formula (Source: wikipedia): This can be calculated with an arbitrary precision. E....
arguments object behave different in strict and non strict mode. In non-strict mode, the argument object will reflect the changes in the value of the parameters which are present, however in strict mode any changes to the value of the parameter will not be reflected in the argument object. function...
PhpStorm offers default settings for code styling for a large amount of languages based on best practices and common standards. But you can customize the styling for each language on a per-project base within the PhpStorm Settings > Editor > Code Style. Schemes Schemes are collections of ...
Currently there is no one-click-button method to actually enforce any code style guidelines across a team but there are two methods to make sure a certain code style is applied to your product. Import PhpStorm Code Style Schemes The first and more easier solution is to set up a code style scheme o...
PhpStorm already ships with a lot of predefined language schemes that are based on common code style guidelines and standards like PSR-2. There is kind of a hidden feature in the code style settings pages where you can import these standards and set them as your current configuration. To do so simp...
By default, Shapes in Excel do not have a specific way to handle single vs. double clicks, containing only the "OnAction" property to allow you to handle clicks. However, there may be instances where your code requires you to act differently (or exclusively) on a double click. The follow...

Page 527 of 1336