Tutorial by Examples: er

Filter an enumeration by using a conditional expression Synonyms: Where-Object where ? Example: $names = @( "Aaron", "Albert", "Alphonse","Bernie", "Charlie", "Danny", "Ernie", "Frank") $names | Where-Object {...
Sort an enumeration in either ascending or descending order Synonyms: Sort-Object sort Assuming: $names = @( "Aaron", "Aaron", "Bernie", "Charlie", "Danny" ) Ascending sort is the default: $names | Sort-Object $names | sort Aaron Aa...
Class methods present alternate ways to build instances of classes. To illustrate, let's look at an example. Let's suppose we have a relatively simple Person class: class Person(object): def __init__(self, first_name, last_name, age): self.first_name = first_name self.last...
class Car { public position: number = 0; protected speed: number = 42; move() { this.position += this.speed; } } class SelfDrivingCar extends Car { move() { // start moving around :-) super.move(); super.move(); } } ...
public class Singleton { private static final Singleton INSTANCE = new Singleton(); private Singleton() {} public static Singleton getInstance() { return INSTANCE; } } It can be argued that this example is effectively lazy initialization. Section 12.4.1 of ...
To implement an item click listener and/or an item long click listener, you can create an interface in your adapter: public class CustomAdapter extends RecyclerView.Adapter<CustomAdapter.ViewHolder> { public interface OnItemClickListener { void onItemSeleted(int position, Vi...
countMatches method from org.apache.commons.lang3.StringUtils is typically used to count occurences of a substring or character in a String: import org.apache.commons.lang3.StringUtils; String text = "One fish, two fish, red fish, blue fish"; // count occurrences of a substring Str...
Method references allow predefined static or instance methods that adhere to a compatible functional interface to be passed as arguments instead of an anonymous lambda expression. Assume that we have a model: class Person { private final String name; private final String surname; ...
Start with an iterable which needs to be grouped lst = [("a", 5, 6), ("b", 2, 4), ("a", 2, 5), ("c", 2, 6)] Generate the grouped generator, grouping by the second element in each tuple: def testGroupBy(lst): groups = itertools.groupby(lst, key=lambda...
To use multiple filters, separate each value with a space. HTML <img src='donald-duck.png' alt='Donald Duck' title='Donald Duck' /> CSS img { -webkit-filter: brightness(200%) grayscale(100%) sepia(100%) invert(100%); filter: brightness(200%) grayscale(100%) sepia(100%) invert(1...
HTML <img src='donald-duck.png' alt='Donald Duck' title='Donald Duck' /> CSS img { -webkit-filter: hue-rotate(120deg); filter: hue-rotate(120deg); } Result
HTML <div></div> CSS div { width: 100px; height: 100px; background-color: white; -webkit-filter: invert(100%); filter: invert(100%); } Result Turns from white to black.
Generally you should avoid using the default database role (often postgres) in your application. You should instead create a user with lower levels of privileges. Here we make one called niceusername and give it a password very-strong-password CREATE ROLE niceusername with PASSWORD 'very-strong-pas...
If we want to iterate backwards through a list or vector we can use a reverse_iterator. A reverse iterator is made from a bidirectional, or random access iterator which it keeps as a member which can be accessed through base(). To iterate backwards use rbegin() and rend() as the iterators for the e...
The arc4random_uniform() function is the simplest way to get high-quality random integers. As per the manual: arc4random_uniform(upper_bound) will return a uniformly distributed random number less than upper_bound. arc4random_uniform() is recommended over constructions like ''arc4random() % uppe...
The following code demonstrates usage of arc4random_uniform() to generate a random integer between 3 and 12: uint32_t randomIntegerWithinRange = arc4random_uniform(10) + 3; // A random integer between 3 and 12 This works to create a range because arc4random_uniform(10) returns an integer between...
When referring to a worksheet, a range or individual cells, it is important to fully qualify the reference. For example: ThisWorkbook.Worksheets("Sheet1").Range(Cells(1, 2), Cells(2, 3)).Copy Is not fully qualified: The Cells references do not have a workbook and worksheet associated ...
C# allows user-defined types to control assignment and casting through the use of the explicit and implicit keywords. The signature of the method takes the form: public static <implicit/explicit> operator <ResultingType>(<SourceType> myType) The method cannot take any more argu...
To generate random permutation of 5 numbers: sample(5) # [1] 4 5 3 1 2 To generate random permutation of any vector: sample(10:15) # [1] 11 15 12 10 14 13 One could also use the package pracma randperm(a, k) # Generates one random permutation of k of the elements a, if a is a vector, # ...
'if only one area (not multiple areas): With Range("A3:D20") Debug.Print .Cells(.Cells.CountLarge).Row Debug.Print .Item(.Cells.CountLarge).Row 'using .item is also possible End With 'Debug prints: 20 'with multiple areas (also works if only one area): Dim rngArea As Range,...

Page 61 of 417