Tutorial by Examples

public static void post(String url, byte [] data, String contentType) throws IOException { HttpURLConnection connection = null; OutputStream out = null; InputStream in = null; try { connection = (HttpURLConnection) new URL(url).openConnection(); connection.set...
A Threadpool has a Queue of tasks, of which each will be executed on one these Threads. The following example shows how to add two int arrays using a Threadpool. Java SE 8 int[] firstArray = { 2, 4, 6, 8 }; int[] secondArray = { 1, 3, 5, 7 }; int[] result = { 0, 0, 0, 0 }; ExecutorService po...
The "child" components of a component are available on a special prop, props.children. This prop is very useful for "Compositing" components together, and can make JSX markup more intuitive or reflective of the intended final structure of the DOM: var SomeComponent = function ...
APT and APT-GET Easiest and fastest way is with apt-get command. This command may be considered as lower-level and "back-end", and support other APT-based tools. There are no fancy loaders, only basic progress info. This is fastest way for installing apps. Usage: sudo apt-get install ...
To check if a method was called on a mocked object you can use the Mockito.verify method: Mockito.verify(someMock).bla(); In this example, we assert that the method bla was called on the someMock mock object. You can also check if a method was called with certain parameters: Mockito.verify(som...
If a scoped enum is converted to an integral type that is too small to hold its value, the resulting value is unspecified. Example: enum class E { X = 1, Y = 1000, }; // assume 1000 does not fit into a char char c1 = static_cast<char>(E::X); // c1 is 1 char c2 = static_cast<c...
While you can use the NSUserDefaults methods anywhere, it can sometimes be better to define a manager that saves and reads from NSUserDefaults for you and then use that manager for reading or writing your data. Suppose that we want to save a user’s score into NSUserDefaults. We can create a class ...
Singletons are a frequently used design pattern which consists of a single instance of a class that is shared throughout a program. In the following example, we create a static property that holds an instance of the Foo class. Remember that a static property is shared between all objects of a class...
Setting overflow value to hidden,auto or scroll to an element, will clear all the floats within that element. Note: using overflow:scroll will always show the scrollbox
Editor templates are a good way to reuse Razor code. You can define editor templates as Razor partial views and then use them in other views. Editor templates usually exist in the Views/Shared/EditorTemplates/ folder, although they can also be saved to the Views/ControllerName/EditorTemplates/ fold...
In IDE Jaspersoft Studio (JSS) or the older version iReport Designer it is sufficient to press Preview. The JasperReports design file .jrxml will automatically be compiled to .jasper in same folder as .jrxml if no errors are present. Another way is to press "Compile Report" button in JSS...
<target name="compile" description="Compiles report designs specified using the 'srcdir' in the <jrc> tag." depends="prepare-compile-classpath"> <mkdir dir="./build/reports"/> <taskdef name="jrc" classname=&quot...
While it is possible to compile .jrxml files into .jasper files using Java code, this incurs a performance hit that is best avoided by pre-compiling .jrxml files using the IDE. With that in mind, compiling .jrxml files can be accomplished using the JasperCompileManager as follows: JasperCompileMana...
Multiple operations can be executed against a single transaction so that changes can be rolled back if any of the operations fail. using (var context = new PlanetContext()) { using (var transaction = context.Database.BeginTransaction()) { try { //Lets assum...
Multidimensional Arrays As the name indicates, multi dimensional arrays are arrays that contain more than one dimension, usually two or three but it can have up to 32 dimensions. A multi array works like a matrix with various levels, take in example a comparison between one, two, and three Dimensi...
Using git show we can view a single commit git show 48c83b3 git show 48c83b3690dfc7b0e622fd220f8f37c26a77c934 Example commit 48c83b3690dfc7b0e622fd220f8f37c26a77c934 Author: Matt Clark <[email protected]> Date: Wed May 4 18:26:40 2016 -0400 The commit message will be show...
When committing changes it is possible to specify that the commit will in future be squashed to another commit and this can be done like so, git commit --squash=[commit hash of commit to which this commit will be squashed to] One might also use, --fixup=[commit hash] alternatively to fixup. It is...
A locator in Protractor is used to perform action on HTML dom elements. The most common and best locators used in Protractor are css, id, model and binding. For example commonly used locators are: by.css('css-selector') by.id('id')
NSLog(@"%s %d %s, yourVariable: %@", __FILE__, __LINE__, __PRETTY_FUNCTION__, yourVariable); Will log the file, line number and function data along with any variables you want to log. This can make the log lines much longer, particularly with verbose file and method names, however it ca...
Sitecore Instance Manager is open-source tool which is used for managing the local park of Sitecore instances. You can install, locate, maintain, reinstal or delete Sitecore products. It also helps you install your sitecore instance with any sitecore packages, modules and only thing you need to do i...

Page 677 of 1336