Tutorial by Examples

Suppose that we have a sequence of integers and we want to create a sequence that contains only the even integers. We can obtain the latter by using the filter function of the Seq module. The filter function has the type signature ('a -> bool) -> seq<'a> -> seq<'a>; this indicat...
-(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 ...
If you are using library that contains (for example) AwesomeViewController with a wrong status bar color you can try this: let awesomeViewController = AwesomeViewController() awesomeViewController.navigationBar.barStyle = .blackTranslucent // or other style
Click the “Move examples” button Select the examples you want to move Click “Move” Select “Search for a Topic” Paste the URL of the topic in the search box Click “Move Examples”. Click “Submit Drafts” or “Edit Drafts”
An interface is declared like a class, but without access modifiers (public, private, ...). Also, no definitions are allowed, so variables and constants can't be used. Interfaces should always have an Unique Identifier, which can be generated by pressing Ctrl + Shift + G. IRepository = interface ...
Classes can implement more than one interface, as opposed to inheriting from more than one class (Multiple Inheritance) which isn't possible for Delphi classes. To achieve this, the name of all interfaces must be added comma-separated behind the base class. Of course, the implementing class must al...
Interfaces can inherit from each other, exactly like classes do, too. An implementing class thus has to implement functions of the interface and all base interfaces. This way, however, the compiler doesn't know that the implenting class also implements the base interface, it only knows of the interf...
Since the declaration of variables in interfaces isn't possible, the "fast" way of defining properites (property Value: TObject read FValue write FValue;) can't be used. Instead, the Getter and setter (each only if needed) have to be declared in the interface, too. IInterface = interface(...
Get a list of all jobs in the current session: Get-Job Waiting on a job to finish before getting the result: $job | Wait-job | Receive-Job Timeout a job if it runs too long (10 seconds in this example) $job | Wait-job -Timeout 10 Stopping a job (completes all tasks that are pending in t...
When using the DllImport attribute you have to know the correct dll and method name at compile time. If you want to be more flexible and decide at runtime which dll and methods to load, you can use the Windows API methods LoadLibrary(), GetProcAddress() and FreeLibrary(). This can be helpful if 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...
A Syntax Tree is an immutable data structure representing the program as a tree of names, commands and marks (as previously configured in the editor.) For example, assume a Microsoft.CodeAnalysis.Compilation instance named compilation has been configured. There are multiple ways to list the names o...
The outline-style property is used to set the style of the outline of an element. p { border: 1px solid black; outline-color:blue; line-height:30px; } .p1{ outline-style: dotted; } .p2{ outline-style: dashed; } .p3{ outline-style: solid; } .p4{ outline-style: double; }...
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...
This command will save the open file with sudo rights :w !sudo tee % >/dev/null You can also map w!! to write out a file as root :cnoremap w!! w !sudo tee % >/dev/null
A mixin is just a module that can be added (mixed in) to a class. one way to do it is with the extend method. The extend method adds methods of the mixin as class methods. module SomeMixin def foo puts "foo!" end end class Bar extend SomeMixin def baz puts "...
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...
:autocmd BufWritePost * if &diff | diffupdate | endif
Get NSData from Hexadecimal String + (NSData *)dataFromHexString:(NSString *)string { string = [string lowercaseString]; NSMutableData *data= [NSMutableData new]; unsigned char whole_byte; char byte_chars[3] = {'\0','\0','\0'}; int i = 0; int length = (int) string.len...
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...

Page 668 of 1336