Tutorial by Examples: er

What's between \Q and \E is treated as normal characters #!/usr/bin/perl my $str = "hello.it's.me"; my @test = ( "hello.it's.me", "hello/it's!me", ); sub ismatched($) { $_[0] ? "MATCHED!" : "DID NOT MATCH!" } my @match = ( ...
Services declaration : # src/Acme/YourBundle/Resources/config/services.yml services: my_service: class: Acme\YourBundle\Service\MyService arguments: ["@doctrine", "%some_parameter%", "@another_service"] another_service: class: Ac...
static TestMethod void DmlTest() { List<Contact> allContacts = [SELECT Id FROM Contact]; System.assert(allContacts.isEmpty()); Contact testContact = new Contact(FirstName = 'John', LastName = 'Doe'); insert testContact; allContacts = [SELECT Id FROM Contact]; Sy...
This time we are going to declare a class decorator that will add some metadata to a class when we applied to it: function addMetadata(target: any) { // Add some metadata target.__customMetadata = { someKey: "someValue" }; // Return target ret...
In the Xcode, you have three separate areas of working - Navigators (in red), Debug area(in green) and Utilities(in blue). The workspace window always includes the editor area. When you select a file in your project, its contents appear in the editor area, where Xcode opens the file in an appropri...
This converter will chain multiple converters together. public class ValueConverterGroup : List<IValueConverter>, IValueConverter { public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { return this.Aggregate(value, (current, converte...
In the root of your project, make sure Bower is installed (npm install -g bower) and run bower init. This will create a bower.json file in your project's directory. Create a new file called .bowerrc to your root directory. It should contain the following: { "directory": "public/b...
To determine the latest tested/supported version of Node that can be used with your installed version of Meteor, dump the node version directly from the build tool's bundled node instance. meteor node -v
The following technique allows you to add your content to an HTML element and center it both horizontally and vertically without worrying about its height or width. The outer container should have display: table; The inner container should have display: table-cell; should have vertical-al...
Read-only properties were always possible in VB.NET in this format: Public Class Foo Private _MyProperty As String = "Bar" Public ReadOnly Property MyProperty As String Get Return _MyProperty End Get End Property End Class The new version of Visual Basi...
Similar to partial classes the new version of Visual Basic is now able to handle partial modules and partial interfaces. The syntax and behaviour is exactly the same as it would be for partial classes. A partial module example: Partial Module Module1 Sub Main() Console.Write("Ping -&g...
In order to use compression over the wire for a faster transfer, pass the --compress option to mysqldump. Example: mysqldump -h db.example.com -u username -p --compress dbname > dbname.sql Important: If you don't want to lock up the source db, you should also include --lock-tables=false. But ...
Some problems can occur if the .git folder has wrong permission. Fixing this problem by setting the owner of the complete .git folder. Sometimes it happen that another user pull and change the rights of the .git folder or files. To fix the problem: chown -R youruser:yourgroup .git/
impl<K, V> Serialize for MyMap<K, V> where K: Serialize, V: Serialize { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer { let mut state = serializer.serialize_map(Some(self.len()))?; ...
// A Visitor is a type that holds methods that a Deserializer can drive // depending on what is contained in the input data. // // In the case of a map we need generic type parameters K and V to be // able to set the output type correctly, but don't require any state. // This is an example of a...
Git shortlog is used to summarize the git log outputs and group the commits by author. By default, all commit messages are shown but argument --summary or -s skips the messages and gives a list of authors with their total number of commits. --numbered or -n changes the ordering from alphabetical (...
git log --pretty=format:"%ai" | awk '{print " : "$1}' | sort -r | uniq -c
git log --pretty=oneline |wc -l
git ls-tree -r HEAD | sed -Ee 's/^.{53}//' | \ while read filename; do file "$filename"; done | \ grep -E ': .*text' | sed -E -e 's/: .*//' | \ while read filename; do git blame --line-porcelain "$filename"; done | \ sed -n 's/^author //p' | \ sort | uniq -c | sort -rn
To validate arguments to methods called on a mock, use the ArgumentCaptor class. This will allow you to extract the arguments into your test method and perform assertions on them. This example tests a method which updates the name of a user with a given ID. The method loads the user, updates the na...

Page 198 of 417