Rust provides two types of documentation comments: inner documentation comments and outer documentation comments. Examples of each are provided below.
Inner Documentation Comments
mod foo {
//! Inner documentation comments go *inside* an item (e.g. a module or a
//! struct). They use th...
Code in documentation comments will automatically be executed by cargo test. These are known as "documentation tests", and help to ensure that your examples work and will not mislead users of your crate.
You can import relative from the crate root (as if there were a hidden extern crate ...
Vaadin plug-in for eclipse provides a quick way to build vaadin project with Apache Ivy dependency manager. Vaadin's documentation explains how to create vaadin project with the help of Eclipse plugin.
To install the plug-in just go to eclipse marketplace and search vaadin. Current version of the p...
Intent:
Separate the construction of a complex object from its representation so that the same construction process can create different representations
Builder pattern is useful when you have few mandatory attributes and many optional attributes to construct a object. To create an object with dif...
Template method pattern is a behavioral design pattern that defines the program skeleton of an algorithm in an operation, defering some steps to subclasses.
Structure:
Key notes:
Template method uses Inheritance
The Template method implemented by the base class should not be overridden. In t...
Often you will want to perform asynchronous operations in parallel. There is direct syntax that supports this in the async/await proposal, but since await will wait for a promise, you can wrap multiple promises together in Promise.all to wait for them:
// Not in parallel
async function getFriend...
Since Java lambdas are closures, they can "capture" the values of variables in the enclosing lexical scope. While not all lambdas capture anything -- simple lambdas like s -> s.length() capture nothing and are called stateless -- capturing lambdas require a temporary object to hold the...
Download:
To set up WebSphere Liberty, download the latest zip from WASdev.net.
Layout:
Once you have the zip, extract it to any location on your file system. The basic layout of a Liberty install is the following:
wlp/ # WLP_INSTALL_DIR
bin/ # location of scrip...
System.Obsolete is an attribute that is used to mark a type or a member that has a better version, and thus should not be used.
[Obsolete("This class is obsolete. Use SomeOtherClass instead.")]
class SomeClass
{
//
}
In case the class above is used, the compiler will give the w...
This method provides you the array buffer start address in memory and number of elements in array. Here is an example:
my_array = array('i', [1,2,3,4,5])
my_array.buffer_info()
(33881712, 5)
Sometimes, if an action should be bind to a collection view's cell selection, you have to implement the UICollectionViewDelegate protocol.
Let's say the collection view is inside a UIViewController MyViewController.
Objective-C
In your MyViewController.h declares that it implements the UICollecti...
-(void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary<NSString *,id> *)change context:(void *)context
Context is important if you ship your class for others to use.Context lets your class observer verify that its you observer which is being called.
The ...
First obtain the Microsoft.CodeAnalysis.CSharp.Workspaces nuget before continuing.
var workspace = Microsoft.CodeAnalysis.MSBuild.MSBuildWorkspace.Create();
var project = await workspace.OpenProjectAsync(projectFilePath);
var compilation = await project.GetCompilationAsync();
foreach (var diag...
Name-based virtual hosting on Apache is described on the Apache website as such:
With name-based virtual hosting, the server relies on the client to
report the hostname as part of the HTTP headers. Using this technique,
many different hosts can share the same IP address.
Therefore, more than...
Add this to your $MYVIMRC:
" Source vim configuration file whenever it is saved
if has ('autocmd') " Remain compatible with earlier versions
augroup Reload_Vimrc " Group name. Always use a unique name!
autocmd! " Clear any preexisting autoc...
Heatmaps are useful for visualizing scalar functions of two variables. They provide a “flat” image of two-dimensional histograms (representing for instance the density of a certain area).
The following source code illustrates heatmaps using bivariate normally distributed numbers centered at 0 in bo...
An SSH key has two pieces, the public key and the private key.
The private key:
Is usually in a file named id_rsa, but it can be given any name.
CANNOT BE REGENERATED IF LOST!!!! Do not lose this file!
If you lose it, you will not be able to get back into your instance. (StackOverflow is li...