Tutorial by Examples

import java.io.FileReader; import java.io.IOException; import javax.script.ScriptEngine; import javax.script.ScriptEngineManager; import javax.script.ScriptException; public class InterfaceImplementationExample { public static interface Pet { public void eat(); } p...
An important principle for unit testing is to separate data access from business logic. One efficient technique for this is to define interfaces for data access. Your main class always use a reference to that interface instead of direct reading or writing data. in production code the main class wil...
GWT ships with a command line utility called webAppCreator that automatically generates all the files you’ll need in order to start a GWT project. It also generates Eclipse project files and launch config files for easy debugging in GWT’s development mode. You can create a new demo application in a...
You should already have your backend REST resource available. On the client side (GWT) your need to Add RestyGwt dependency to your project with maven <dependency> <groupId>org.fusesource.restygwt</groupId> <artifactId>restygwt</artifactId> <vers...
// Obtain an instance of JavaScript engine ScriptEngineManager manager = new ScriptEngineManager(); ScriptEngine engine = manager.getEngineByName("nashorn"); try { // Set value in the global name space of the engine engine.put("name","Nashorn"); // E...
import java.util.ArrayList; import java.util.List; import static java.lang.System.out; public class PolymorphismDemo { public static void main(String[] args) { List<FlyingMachine> machines = new ArrayList<FlyingMachine>(); machines.add(new FlyingMachine())...
The way to do a JAX-WS call with basic authentication is a little unobvious. Here is an example where Service is the service class representation and Port is the service port you want to access. Service s = new Service(); Port port = s.getPort(); BindingProvider prov = (BindingProvider)port; ...
This function copies data between two streams - void copy(InputStream in, OutputStream out) throws IOException { byte[] buffer = new byte[8192]; while ((bytesRead = in.read(buffer)) > 0) { out.write(buffer, 0, bytesRead); } } Example - // reading from System.in and ...
Let's say you have this line of code: printf("Hello, world!\n"); Now say you want to change the text to "Program exiting." CommandBufferMnemonicci"printf("¦");change in the ".Program exiting.\n<esc>printf("Program exiting.\n");
Like it mentions in the remarks section we need to supply two functions. A vertex shader and a fragment shader Let's start with a vertex shader // an attribute will receive data from a buffer attribute vec4 position; // all shaders have a main function void main() { // gl_Position is a s...
git log master..foo will show the commits that are on foo and not on master. Helpful for seeing what commits you've added since branching!
In Python 2, any integer larger than a C ssize_t would be converted into the long data type, indicated by an L suffix on the literal. For example, on a 32 bit build of Python: Python 2.x2.7 >>> 2**31 2147483648L >>> type(2**31) <type 'long'> >>> 2**30 10737418...
Sometimes you will make a mistake with a lengthy macro, but would rather edit it than re-record it entirely. You can do this using the following process: Put the macro on an empty line with "<register>p. If your macro is saved in register a, the command is "ap. Edit the ma...
Using else we can perform some task when the condition is not satisfied. But what if we want to check a second condition in case that the first one was false. We can do it this way: a = 9; if mod(a,2)==0 % MOD - modulo operation, return the remainder after division of 'a' by 2 disp('a is ev...
When we use a condition within another condition we say the conditions are "nested". One special case of nested conditions is given by the elseif option, but there are numerous other ways to use nested conditons. Let's examine the following code: a = 2; if mod(a,2)==0 % MOD - modulo o...
To check if a required gem is installed, from within your code, you can use the following (using nokogiri as an example): begin found_gem = Gem::Specification.find_by_name('nokogiri') require 'nokogiri' .... <the rest of your code> rescue Gem::LoadError end However, this can ...
This can be easily accomplished by calling Enumerable#to_a on a Range object: (1..10).to_a #=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] (a..b) means that it will include all numbers between a and b. To exclude the last number, use a...b a_range = 1...5 a_range.to_a #=> [1, 2, 3, 4] or...
While in insert mode, you can use <C-r> to paste from a register, which is specified by the next keystroke. <C-r>" for example pastes from the unnamed (") register. See :help registers.
The MAF file format is a tab-delimited text file format intended for describing somatic DNA mutations detected in sequencing results, and is distinct from the Multiple Alignment Format file type, which is intended for representing aligned nucleotide sequences. Column headers and ordering may someti...
Suppose we want to select a word with a surrounding white space, use the text object aw for around a word using visual mode: Got to normal mode by pressing ESC Type vaw at the beginning of a word This will select the word with white space

Page 551 of 1336