Tutorial by Examples: ti

When to use Virtually all WPF controls make heavy use of dependency properties. A dependency property allows for the use of many WPF features that are not possible with standard CLR properties alone, including but not limited to support for styles, animations, data binding, value inheritance, and c...
When to use An attached property is a dependency property that can be applied to any DependencyObject to enhance the behavior of various controls or services that are aware of the property's existence. Some use cases for attached properties include: Having a parent element iterate through its c...
When to use A read-only dependency property is similar to a normal dependency property, but it is structured to not allow having its value set from outside the control. This works well if you have a property that is purely informational for consumers, e.g. IsMouseOver or IsKeyboardFocusWithin. How...
To prompt for credentials, you should almost always use the Get-Credential cmdlet: $credential = Get-Credential Pre-filled user name: $credential = Get-Credential -UserName 'myUser' Add a custom prompt message: $credential = Get-Credential -Message 'Please enter your company email address a...
To store and retrieve encrypted credentials easily, use PowerShell's built-in XML serialization (Clixml): $credential = Get-Credential $credential | Export-CliXml -Path 'C:\My\Path\cred.xml' To re-import: $credential = Import-CliXml -Path 'C:\My\Path\cred.xml' The important thing to remem...
Check if a path is a directory or a file The is_dir function returns whether the argument is a directory, while is_file returns whether the argument is a file. Use file_exists to check if it is either. $dir = "/this/is/a/directory"; $file = "/this/is/a/file.txt"; echo is_d...
You can get the number of elements inside the set using the .size property const mySet = new Set([1, 2, 2, 3]); mySet.add(4); mySet.size; // 4 This property, unlike Array.prototype.length, is read-only, which means that you can't change it by assigning something to it: mySet.size = 5; mySet....
Unlike many other languages, Perl does not have constructors that allocate memory for your objects. Instead, one should write a class method that both create a data structure and populate it with data (you may know it as the Factory Method design pattern). package Point; use strict; sub new { ...
To make a class a subclass of another class, use parent pragma: package Point; use strict; ... 1; package Point2D; use strict; use parent qw(Point); ... 1; package Point3D; use strict; use parent qw(Point); ... 1; Perl allows for multiple inheritance: package Point2D; use stri...
To filter a selection you can use the .filter() method. The method is called on a selection and returns a new selection. If the filter matches an element then it is added to the returned selection, otherwise it is ignored. If no element is matched then an empty selection is returned. The HTML Thi...
Until Java 8, two instances of the same annotation could not be applied to a single element. The standard workaround was to use a container annotation holding an array of some other annotation: // Author.java @Retention(RetentionPolicy.RUNTIME) public @interface Author { String value(); } ...
Collections in Java only work for objects. I.e. there is no Map<int, int> in Java. Instead, primitive values need to be boxed into objects, as in Map<Integer, Integer>. Java auto-boxing will enable transparent use of these collections: Map<Integer, Integer> map = new HashMap<&g...
The dir() function can be used to get a list of the members of a class: dir(Class) For example: >>> dir(list) ['__add__', '__class__', '__contains__', '__delattr__', '__delitem__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__getitem__', '__gt__', '__...
ISO/ANSI SQL: SELECT * FROM TableName FETCH FIRST 20 ROWS ONLY; MySQL; PostgreSQL; SQLite: SELECT * FROM TableName LIMIT 20; Oracle: SELECT Id, Col1 FROM (SELECT Id, Col1, row_number() over (order by Id) RowNumber FROM TableName) WHERE RowNumber <= 2...
ISO/ANSI SQL: SELECT Id, Col1 FROM TableName ORDER BY Id OFFSET 20 ROWS FETCH NEXT 20 ROWS ONLY; MySQL: SELECT * FROM TableName LIMIT 20, 20; -- offset, limit Oracle; SQL Server: SELECT Id, Col1 FROM (SELECT Id, Col1, row_number() over (order by Id) RowNumbe...
See also the Mercurial Tutorial Creating a Mercurial Repository A Mercurial repository is simply a directory (referred to as the "working directory") containing an .hg directory with metadata about the contents of the repository. This makes Mercurial very lightweight and easy to start us...
Options have some useful higher-order functions that can be easily understood by viewing options as collections with zero or one items - where None behaves like the empty collection, and Some(x) behaves like a collection with a single item, x. val option: Option[String] = ??? option.map(_.trim) ...
Panels can have sections, sections can have settings, and settings can have controls. Settings are saved in the database, while the controls for particular settings are only used to display their corresponding setting to the user. This code creates a basic section in the panel from above. Inside a...
Add typings to your package.json { ... "typings": "path/file.d.ts" ... } Now when ever that library is imported typescript will load the typings file
Data classes in kotlin are classes created to do nothing but hold data. Such classes are marked as data: data class User(var firstname: String, var lastname: String, var age: Int) The code above creates a User class with the following automatically generated: Getters and Setters for all prope...

Page 145 of 505