QModelIndex does not actually know about it's parent/child indexes, it only contains a row, a column and a pointer, and it is the models responsibility to use this data to provide information an index's relations. The model therefore needs to do a lot of conversions from the void* stored inside the ...
The igraph package for R is a wonderful tool that can be used to model networks, both real and virtual, with simplicity. This example is meant to demonstrate how to create two simple network graphs using the igraph package within R v.3.2.3.
Non-Directed Network
The network is created with this pie...
One can verify whether a method was called on a mock by using Mockito.verify().
Original mock = Mockito.mock(Original.class);
String param1 = "Expected param value";
int param2 = 100; // Expected param value
//Do something with mock
//Verify if mock was used properly
Mockito.veri...
Often you will want to perform asynchronous operations in parallel. There is direct syntax that supports this in the async/await proposal, but since await will wait for a promise, you can wrap multiple promises together in Promise.all to wait for them:
// Not in parallel
async function getFriend...
We shall create a simple Alert Dialog in Xamarin.Android
Now considering you have gone through the getting started guide from the documentation.
You must be having the project structure like this:
Your Main Activity must be looking like this:
public class MainActivity : Activity
{
...
A mixin is just a module that can be added (mixed in) to a class. one way to do it is with the extend method. The extend method adds methods of the mixin as class methods.
module SomeMixin
def foo
puts "foo!"
end
end
class Bar
extend SomeMixin
def baz
puts "...
Usage
Sometimes, you could have to debug code in another PhpStorm project, you have to update the configuration.
PHP configuration
In php.ini, edit file and put xdebug.remote_autostart = 1
PhpStorm configuration
You also have to configure your IDE:
In the phpStorm configuration, Max. sim...
This code sends a simple text-only email to [email protected]
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'The Profile Name',
@recipients = '[email protected]',
@body = 'This is a simple email sent from SQL Server.',
@subject = 'Simple email'
Sitecore Instance Manager is open-source tool which is used for managing the local park of Sitecore instances. You can install, locate, maintain, reinstal or delete Sitecore products. It also helps you install your sitecore instance with any sitecore packages, modules and only thing you need to do i...
Asp.net is web application framework developed by Microsoft to build dynamic data-driven Web Application and WebServices.
Asp.net is basically a subset of wider .NET framework. A framework is nothing but a collection of classes.
In .NET Framework you can build Console application. Web Applicatio...
First of all we need to add SQLite support to our application. There are two ways of doing that
Download DLL suiting your system from SQLite download page and then add to the project manually
Add SQLite dependency via NuGet
We'll do it the second way
First open the NuGet menu
and search f...
Introduction
The PHPUnit Manual describes mocking as such:
The practice of replacing an object with a test double that verifies
expectations, for instance asserting that a method has been called, is
referred to as mocking.
So instead of stubbing out code, an observer is created that not onl...
Get the current date and time.
public class Program
{
static void Main()
{
// create empty pipeline
PowerShell ps = PowerShell.Create();
// add command
ps.AddCommand("Get-Date");
// run command(s)
Console.WriteLine("...
# The following shell function will be used to generate completions for
# the "nuance_tune" command.
_nuance_tune_opts ()
{
local curr_arg prev_arg
curr_arg=${COMP_WORDS[COMP_CWORD]}
prev_arg=${COMP_WORDS[COMP_CWORD-1]}
# The "config" option takes a file arg, so ...
Let us first create a simple .proto file person.proto
package Protocol;
message Person {
required string firstName = 1;
required string lastName = 2;
optional int32 age = 3;
}
After saving we can now create the Haskell files which we can use in our project by running
...
Python follows PEMDAS rule. PEMDAS stands for Parentheses, Exponents, Multiplication and Division, and Addition and Subtraction.
Example:
>>> a, b, c, d = 2, 3, 5, 7
>>> a ** (b + c) # parentheses
256
>>> a * b ** c # exponent: same as `a * (b ** c)`
7776
>>...
This class is called Greeter. Its responsibility is to output a greeting. It has two dependencies. It needs something that will give it the greeting to output, and then it needs a way to output that greeting. Those dependencies are both described as interfaces, IGreetingProvider and IGreetingWriter....
Here's a simple example that uses XSLT to convert data in an XML file into a table in an HTML file. You can use it to experiment with simple XSLT transforms.
Prerequisite: Install a Java Runtime Environment and add the location of the JRE to your PATH variable. (On Windows, most installers will add...
To create a Swift Package, open a Terminal then create an empty folder:
mkdir AwesomeProject
cd AwesomeProject
And init a Git repository:
git init
Then create the package itself. One could create the package structure manually but there's a simple way using the CLI command.
If you want to ...