Tutorial by Examples

The password in a credential object is an encrypted [SecureString]. The most straightforward way is to get a [NetworkCredential] which does not store the password encrypted: $credential = Get-Credential $plainPass = $credential.GetNetworkCredential().Password The helper method (.GetNetworkCrede...
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...
Tuples are useful to swap values between 2 (or more) variables without using temporary variables. Example with 2 variables Given 2 variables var a = "Marty McFly" var b = "Emmett Brown" we can easily swap the values (a, b) = (b, a) Result: print(a) // "Emmett Bro...
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...
The Common Lisp Quick Reference is a document which can be printed and bound as a booklet in various layouts to have a printed quick reference for Common Lisp.
You can remove all the elements in a set using the .clear() method: mySet.clear();
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 { ...
In general, classes in Perl are just packages. They can contain data and methods, as usual packages. package Point; use strict; my $CANVAS_SIZE = [1000, 1000]; sub new { ... } sub polar_coordinates { ... } 1; It is important to note that the variables declared in a packa...
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...
In Perl, the difference between class (static) and object (instance) methods is not so strong as in some other languages, but it still exists. The left operand of the arrow operator -> becomes the first argument of the method to be called. It may be either a string: # the first argument of new ...
To get the previous element you can use the .prev() method. <ul> <li>Mark</li> <li class="anna">Anna</li> <li>Paul</li> </ul> If you are standing on the "Anna" element and you want to get the previous element, &q...
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(); } ...
This will create a composite index of both keys, mystring and mydatetime and speed up queries with both columns in the WHERE clause. CREATE INDEX idx_mycol_myothercol ON my_table(mycol, myothercol) Note: The order is important! If the search query does not include both columns in the WHERE claus...
On Debian-based distributions, including Ubuntu, the most straightforward way is to use the .deb installation file. Go to the Scala website. Choose the version you want to install then scroll down and look for scala-x.x.x.deb. You can install the scala deb from command line: sudo dpkg -i scala-x.x...
Most developers encounter backpressure when their application fails with MissingBackpressureException and the exception usually points to the observeOn operator. The actual cause is usually the non-backpressured use of PublishSubject, timer() or interval() or custom operators created via create(). ...
base.twig.html <!DOCTYPE html> <html> <head> <title>{{ title | default('Hello World') }}</title> <link rel="stylesheet" type="text/css" href="theme.css"> {% block css %} {% endblock %} &...
article.twig.html <article> <h1>{{ article.title }}</h1> {% block content %} <p>{{ article.content }}</p> {% endblock %} </article> articles.twig.html {# use default template for article #} {% for article in articles %} {% include &...
In this case, "monkey patching" means adding a new variable or method to a class after it's been defined. For instance, say we defined class A as class A(object): def __init__(self, num): self.num = num def __add__(self, other): return A(self.num + other.num)...

Page 376 of 1336