Tutorial by Examples

If you would like to use vim in a manner similar to sed, you may use the -c flag to run an ex command from the command line. This command will run automatically before presenting the file to you. For example, to replace foo with bar: vim file.txt -c "s/foo/bar" This will open up the fi...
To create the serialVersionUID for a class in Kotlin you have a few options all involving adding a member to the companion object of the class. The most concise bytecode comes from a private const val which will become a private static variable on the containing class, in this case MySpecialCase: ...
// this function add custom interval (5 minutes) to the $schedules function five_minutes_interval( $schedules ) { $schedules['five_minutes'] = array( 'interval' => 60 * 5, 'display' => '5 minutes'; ); return $schedules; } // add a custom in...
The hash codes produced by GetHashCode() method for built-in and common C# types from the System namespace are shown below. Boolean 1 if value is true, 0 otherwise. Byte, UInt16, Int32, UInt32, Single Value (if necessary casted to Int32). SByte ((int)m_value ^ (int)m_value << 8); Char...
Generally, it's not a good idea to use a regular expression to parse a complex structure. But it can be done. For instance, you might want to load data into hive table and fields are separated by comma but complex types like array are separated by a "|". Files contain records with all fiel...
The java command supports a wide range of options: All options start with a single hyphen or minus-sign (-): the GNU/Linux convention of using -- for "long" options is not supported. Options must appear before the <classname> or the -jar <jarfile> argument to be recog...
Fluent methods in Kotlin can be the same as Java: fun doSomething() { someOtherAction() return this } But you can also make them more functional by creating an extension function such as: fun <T: Any> T.fluently(func: ()->Unit): T { func() return this } Which the...
The BukkitRunnable is a Runnable found in Bukkit. It's possible to schedule a task directly from a BukkitRunnable, and also cancel it from inside itself. Important: The time on the tasks is measured in Ticks. A second has 20 ticks. Non-RepeatingTask: JavaPlugin plugin; //Your plugin instance ...
Enable the module by typing: sudo a2enmod ssl Restart the web server (apache2) so the change is recognized: sudo service apache2 restart Optional (but a good idea): Create a directory that will contain our new certificate files: sudo mkdir /etc/apache2/ssl Create the key and self-signed ...
Pointers can be dereferenced by adding an asterisk * before a pointer. package main import ( "fmt" ) type Person struct { Name string } func main() { c := new(Person) // returns pointer c.Name = "Catherine" fmt.Println(c.Name) // prints: Cathe...
A question that occasionally on StackOverflow is whether it is appropriate to use assert to validate arguments supplied to a method, or even inputs provided by the user. The simple answer is that it is not appropriate. Better alternatives include: Throwing an IllegalArgumentException using cust...
You can have a config.yml file that loads directly from your jar file. It must be added to your project's folder, the same way as the plugin.yml file is. In this file you have the default values for your configuration. Example config: # This is an YML comment adminName: "Kerooker" mod...
What can happen in your config file is having a path to a variable that goes through multiple sections. Example Config admins: first-tier: "Kerooker" second-tier: "Mordekaiser" third-tier: "Yesh4" The name "Kerooker" is from section "first-tier...
Instead of getting a reference to the DOM you can simply change the index of the tab using the selectedIndex attribute on the ion-tabs HTML: <ion-tabs [selectedIndex]="tabIndex" class="tabs-icon-text" primary > <ion-tab tabIcon="list-box" [root]=&qu...
Sometimes it is needful to backtrack after reading. # identify current position in file, in case the first line isn't a comment my $current_pos = tell; while (my $line = readline $fh) { if ($line =~ /$START_OF_COMMENT_LINE/) { push @names, get_name_from_comment($line); ...
The WMI type provider allows you to query WMI services with strong typing. To output the results of a WMI query as JSON, open FSharp.Management open Newtonsoft.Json // `Local` is based off of the WMI available at localhost. type Local = WmiProvider<"localhost"> let data = ...
Some of the simplest kinds of classes are POCOs. // C# public class Person { public string FirstName { get; set; } public string LastName { get; set; } public DateTime Birthday { get; set; } } In F# 3.0, auto-properties similar to C# auto-properties were introduced, // F# typ...
Classes implement an interface to meet the interface's contract. For example, a C# class may implement IDisposable, public class Resource : IDisposable { private MustBeDisposed internalResource; public Resource() { internalResource = new MustBeDisposed(); } ...
A Receiver Operating Characteristic (ROC) curve plots the TP-rate vs. the FP-rate as a threshold on the confidence of an instance being positive is varied Algorithm for creating an ROC curve sort test-set predictions according to confidence that each instance is positive step through ...
If you need to check if your testing method takes too long to execute, you can do that by mentioning your expected execution time using timeout property of @Test annotation. If the test execution takes longer than that number of milliseconds it causes a test method to fail. public class StringConca...

Page 927 of 1336