Tutorial by Examples: dis

var numbers = new[] {1, 1, 2, 2, 3, 3, 4, 4, 5, 5}; var distinctNumbers = numbers.Distinct(); Console.WriteLine(string.Join(",", distinctNumbers)); //1,2,3,4,5
Subscription returns an IDisposable: IDisposable subscription = emails.Subscribe(email => Console.WriteLine("Email from {0} to {1}", email.From, email.To)); When you are ready to unsubscribe, simply dispose the subscription: subscription.Dispose();
The following is a bad idea because it would dispose the db variable before returning it. public IDBContext GetDBContext() { using (var db = new DBContext()) { return db; } } This can also create more subtle mistakes: public IEnumerable<Person> GetPeople(int age)...
R has several built-in functions that can be used to print or display information, but print and cat are the most basic. As R is an interpreted language, you can try these out directly in the R console: print("Hello World") #[1] "Hello World" cat("Hello World\n") #H...
If it's not already done in php.ini, error reporting can be set dynamically and should be set to allow most errors to be shown: Syntax int error_reporting ([ int $level ] ) Examples // should always be used prior to 5.4 error_reporting(E_ALL); // -1 will show every possible error, even whe...
Dropbox.authorizedClient!.files.listFolder(path: "").response { response, error in print("*** List folder ***") if let result = response { print("Folder contents:") for entry in result.entries { print(entry.name) if ...
For Alerts since iOS 8, you would use a UIAlertController but for versions before, you would have used a UIAlertView, which is now deprecated. 8.0 var alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create(otherTitle, UIAlertActionStyl...
We can make an AJAX request to Stack Exchange's API to retrieve a list of the top JavaScript questions for the month, then present them as a list of links. If the request fails or the returns an API error, our promise error handling displays the error instead. 6 View live results on HyperWeb. c...
Use the --number flag to print line numbers before each line. Alternatively, -n does the same thing. $ cat --number file 1 line 1 2 line 2 3 4 line 4 5 line 5 To skip empty lines when counting lines, use the --number-nonblank, or simply -b. $ cat -b file 1 line 1 2 line ...
$( "#accordion" ).accordion( "disable" ); This method will disable the accordion, i.e. the headers are not selectable making the content read only and static. This method does not take any arguments.
While inside a Razor code block, the browser will only recognize HTML code if the code is escaped. Use @: for a Single line: @foreach(int number in Model.Numbers) { @:<h1>Hello, I am a header!</h1> } Use <text> ... </text> for Multi-line: @{ var number = 1; ...
This is a continuous collector that uses the hadoop fs -du -s /hbase/* command to get details about the HDFS disk usage. This metric is very useful for tracking space in an OpenTSDB system. #!/bin/bash while true; do while read -r bytes raw_bytes path; do echo "hdfs.du $(date +&...
The static (compile-time) type is used rather than the dynamic (run-time type) to match parameters. public class Base { public virtual string GetName() { return "Base"; } } public class Derived : Base { public override string GetName() { ...
Just execute lsb_release -a. On Debian: $ lsb_release -a No LSB modules are available. Distributor ID: Debian Description: Debian GNU/Linux testing (stretch) Release: testing Codename: stretch On Ubuntu: $ lsb_release -a No LSB modules are available. Distributor ID: Ubun...
By default error message appears below textbox in <div class="help-block"></div> on keyUp or after pressing submit button if any validation constraints aren't met. Sometimes we want a message on submit only i.e. no validation at onKeyup event. Let's check yii2/widgets/ActiveF...
A button can be disabled by Swift myButton.isEnabled = false Objective-C: myButton.enabled = NO; The button will become gray: If you don't want the button appearance to change when disabled set adjustsImageWhenDisabled to false / NO
When defining discriminated unions you can name elements of tuple types and use these names during pattern matching. type Shape = | Circle of diameter:int | Rectangle of width:int * height:int let shapeIsTenWide = function | Circle(diameter=10) | Rectangle(width=10) -> t...
Returns unique values from an IEnumerable. Uniqueness is determined using the default equality comparer. int[] array = { 1, 2, 3, 4, 2, 5, 3, 1, 2 }; var distinct = array.Distinct(); // distinct = { 1, 2, 3, 4, 5 } To compare a custom data type, we need to implement the IEquatable<T> i...
Discriminated unions in F# offer a a way to define types which may hold any number of different data types. Their functionality is similar to C++ unions or VB variants, but with the additional benefit of being type safe. // define a discriminated union that can hold either a float or a string type...
The following code is for iOS 8 and lower for creating a login alert. // Create the UIAlertView var loginAlertView = new UIAlertView(title, message, null, cancelTitle, okTitle); // Setting the AlertViewStyle to UIAlertViewStyle.LoginAndPasswordInput loginAlertView.AlertViewStyle = UIAlertViewS...

Page 1 of 18