Tutorial by Examples: sin

Consider the Node class having 3 members data, left child pointer and right child pointer like below. public class Node { public int data; public Node left; public Node right; public Node(int data){ this.data = data; } } We can traverse the tree construct...
First you have to set up a new Scrapy project. Enter a directory where you’d like to store your code and run: scrapy startproject projectName To scrape we need a spider. Spiders define how a certain site will be scraped. Here’s the code for a spider that follows the links to the top voted questi...
About Akavache Akavache is an incredibly useful library providing reach functionality of caching your data. Akavache provides a key-value storage interface and works on the top of SQLite3. You do not need to keep your schema synced as it's actually No-SQL solution which makes it perfect for most of...
In your Storyboard, add a UITableView object on your UIViewController and let it cover the entire view. Setup the UITableviewDataSource and UITableviewDelegate connections. Objective-C In your .h file NSMutableArray *arrayForBool; NSMutableArray *sectionTitleArray; In your .m file - (void)vi...
We can directly copy data from a source to a data sink using a loop. In this example, we are reading data from an InputStream and at the same time, writing to an OutputStream. Once we are done reading and writing, we have to close the resource. public void copy(InputStream source, OutputStream dest...
Channel uses a Buffer to read/write data. A buffer is a fixed sized container where we can write a block of data at once. Channel is a quite faster than stream-based I/O. To read data from a file using Channel we need to have the following steps- We need an instance of FileInputStream. FileInput...
Swift: if let url = URL(string: "mailto://[email protected]") { if UIApplication.shared.canOpenURL(url) { UIApplication.shared.openURL(url) } else { print("Cannot open URL") } } Objective-C: NSURL *url = [NSURL URLWithString:@"mailto://az...
The C standard says that files should end with a new line, so if EOF comes at the end of a line, that line may not be missed by some commands. As an example: $ echo 'one\ntwo\nthree\c' > file.txt $ cat file.txt one two three $ while read line ; do echo "line $line" ; done <...
Provides the total number of records processed by the awk instance relative to the files awk is processing cat > file1 suicidesquad harley quinn joker deadshot cat > file2 avengers ironman captainamerica hulk awk '{print FNR}' file1 file2 1 2 3 4 1 2 3 4 Each file had...
expr or Evaluate expressions evaluates an expression and writes the result on standard output Basic arithmetics expr 2 + 3 5 When multiplying, you need to escape the * sign expr 2 \* 3 6 You can also use variables a=2 expr $a + 3 5 Keep in mind that it only supports integers, so exp...
Setup First, install the necessary packages with: npm install express cors mongoose Code Then, add dependencies to server.js, create the database schema and the name of the collection, create an Express.js server, and connect to MongoDB: var express = require('express'); var cors = require('...
Use $this to refer to the current object. Use self to refer to the current class. In other words, use $this->member for non-static members, use self::$member for static members. In the example below, sayHello() and sayGoodbye() are using self and $this difference can be observed here. cl...
You might have heard that everything in Python is an object, even literals. This means, for example, 7 is an object as well, which means it has attributes. For example, one of these attributes is the bit_length. It returns the amount of bits needed to represent the value it is called upon. x = 7 ...
Since Java 7 it has been possible to use one or more underscores (_) for separating groups of digits in a primitive number literal to improve their readability. For instance, these two declarations are equivalent: Java SE 7 int i1 = 123456; int i2 = 123_456; System.out.println(i1 == i2); // tru...
/*(8)*/ SELECT /*9*/ DISTINCT /*11*/ TOP /*(1)*/ FROM /*(3)*/ JOIN /*(2)*/ ON /*(4)*/ WHERE /*(5)*/ GROUP BY /*(6)*/ WITH {CUBE | ROLLUP} /*(7)*/ HAVING /*(10)*/ ORDER BY /*(11)*/ LIMIT The order in which a query is processed and description of each section. V...
Assuming you have a Twilio account and API credentials, add the following to your Gemfile: gem 'twilio-ruby' Alternatively you can gem install twilio-ruby. To have Twilio send an incoming SMS to a particular route in your application, you need to configure the Messaging URL for your phone numbe...
Web applications often require static files like CSS or JavaScript files. To use static files in a Flask application, create a folder called static in your package or next to your module and it will be available at /static on the application. An example project structure for using templates is as f...
XE2 program CrossPlatformHelloWorld; uses FMX.Dialogs; {$R *.res} begin ShowMessage('Hello world!'); end. Most of the Delphi supported platforms (Win32/Win64/OSX32/Android32/iOS32/iOS64) also support a console so the WriteLn example fits them well. For the platforms that require...
Dim aList as New List(Of String) aList.Add("one") aList.Add("two") aList.Add("three") For Each str As String in aList System.Console.WriteLine(str) Next Produces the following output: one two three Another option, would be to loop through using the ...
Overview: The default data type for numeric arrays in MATLAB is double. double is a floating point representation of numbers, and this format takes 8 bytes (or 64 bits) per value. In some cases, where e.g. dealing only with integers or when numerical instability is not an imminent issue, such high ...

Page 57 of 161