Tutorial by Examples: comp

To split one component off of the path: >>> p = os.path.join(os.getcwd(), 'foo.txt') >>> p '/Users/csaftoiu/tmp/foo.txt' >>> os.path.dirname(p) '/Users/csaftoiu/tmp' >>> os.path.basename(p) 'foo.txt' >>> os.path.split(os.getcwd()) ('/Users/csafto...
Rcpp features two functions that enable code compilation inline and exportation directly into R: cppFunction() and evalCpp(). A third function called sourceCpp() exists to read in C++ code in a separate file though can be used akin to cppFunction(). Below is an example of compiling a C++ function w...
Actually you can use ReactJS's components in Typescript as in facebook's example. Just replace 'jsx' file's extension to 'tsx': //helloMessage.tsx: var HelloMessage = React.createClass({ render: function() { return <div>Hello {this.props.name}</div>; } }); ReactDOM.rende...
This is an extension of Basic Example: Basic Structure import React, { Component } from 'react'; import { render } from 'react-dom'; class FirstComponent extends Component { render() { return ( <div> Hello, {this.props.name}! I am a FirstCompon...
Intents can be used to broadcast messages to other components of your application (such as a running background service) or to the entire Android system. To send a broadcast within your application, use the LocalBroadcastManager class: Intent intent = new Intent("com.example.YOUR_ACTION"...
Comparable is one of the most popular modules in Ruby. Its purpose is to provide with convenience comparison methods. To use it, you have to include Comparable and define the space-ship operator (<=>): class Rectangle include Comparable def initialize(a, b) @a = a @b = b ...
There are 4 methods for comparing dates: Swift isEqualToDate(anotherDate: NSDate) -> Bool earlierDate(anotherDate: NSDate) -> NSDate laterDate(anotherDate: NSDate) -> NSDate compare(anotherDate: NSDate) -> NSComparisonResult Objective-C - (BOOL)isEqualToDate:(NSDate *)anothe...
You can compare BigIntegers same as you compare String or other objects in Java. For example: BigInteger one = BigInteger.valueOf(1); BigInteger two = BigInteger.valueOf(2); if(one.equals(two)){ System.out.println("Equal"); } else{ System.out.println("Not Equal"...
async functions do not replace the Promise type; they add language keywords that make promises easier to call. They are interchangeable: async function doAsyncThing() { ... } function doPromiseThing(input) { return new Promise((r, x) => ...); } // Call with promise syntax doAsyncThing() ...
If value types are assigned to variables of type object they are boxed - the value is stored in an instance of a System.Object. This can lead to unintended consequences when comparing values with ==, e.g.: object left = (int)1; // int in an object box object right = (int)1; // int in an object bo...
\bfoo\b will match the complete word with no alphanumeric and _ preceding or following by it. Taking from regularexpression.info There are three different positions that qualify as word boundaries: Before the first character in the string, if the first character is a word character. After...
Tuples can be compared based on their elements. As an example, an enumerable whose elements are of type Tuple can be sorted based on comparisons operators defined on a specified element: List<Tuple<int, string>> list = new List<Tuple<int, string>>(); list.Add(new Tuple<...
Arrays You can iterate over nested arrays: [[1, 2], [3, 4]].each { |(a, b)| p "a: #{ a }", "b: #{ b }" } The following syntax is allowed too: [[1, 2], [3, 4]].each { |a, b| "a: #{ a }", "b: #{ b }" } Will produce: "a: 1" "b: 2" ...
DateTime date1 = new DateTime(2009, 8, 1, 0, 0, 0); DateTime date2 = new DateTime(2009, 8, 1, 12, 0, 0); int result = DateTime.Compare(date1, date2); string relationship; if (result < 0) relationship = "is earlier than"; else if (result == 0) relationship = "is the...
The following example demonstrates the use of a BackgroundWorker to update a WinForms ProgressBar. The backgroundWorker will update the value of the progress bar without blocking the UI thread, thus showing a reactive UI while work is done in the background. namespace BgWorkerExample { public...
Elixir doesn't have loops. Instead of them for lists there are great Enum and List modules, but there are also List Comprehensions. List Comprehensions can be useful to: create new lists iex(1)> for value <- [1, 2, 3], do: value + 1 [2, 3, 4] filtering lists, using guard expressi...
You can broadcast more complex messages by serializing the payload before you publish it: // definition of a message public class ChatMessage { public Guid Id { get; set; } public string User { get; set; } public string Text { get; set; } } // grab an instance of an ISubscriber...
StackExchange.Redis also supports sending bytes over the pub/sub channel, here we use protobuf-net to serialize our message to a byte array before sending it: // definition of a message (marked up with Protobuf attributes) [ProtoContract] public class ChatMessage { [ProtoMember(1)] pub...
NSString *urlString = @"https://www.stackoverflow.com"; NSURL *myUrl = [NSURL URLWithString: urlString]; NSURL *myUrl2 = [NSURL URLWithString: urlString]; if ([myUrl isEqual:myUrl2]) return YES;
For simple array comparison you can use JSON stringify and compare the output strings: JSON.stringify(array1) === JSON.stringify(array2) Note: that this will only work if both objects are JSON serializable and do not contain cyclic references. It may throw TypeError: Converting circular struct...

Page 5 of 34