Bear in mind that declaring a destructor inhibits the compiler from generating implicit move constructors and move assignment operators. If you declare a destructor, remember to also add appropriate definitions for the move operations.
Furthermore, declaring move operations will suppress the genera...
When creating a recyclerview with a gridlayout layout manager you have to specify the span count in the constructor. Span count refers to the number of columns. This is fairly clunky and doesn't take into account larger screen sizes or screen orientation. One approach is to create multiple layouts f...
To add a header to a recyclerview with a gridlayout, first the adapter needs to be told that the header view is the first position - rather than the standard cell used for the content. Next, the layout manager must be told that the first position should have a span equal to the *span count of the e...
Using the Array::new constructor, your can initialize an array with a given size and a new array in each of its slots. The inner arrays can also be given a size and and initial value.
For instance, to create a 3x4 array of zeros:
array = Array.new(3) { Array.new(4) { 0 } }
The array generated a...
Define your class that will represent your custom error.
public class ErrorDto
{
public int Code { get; set; }
public string Message { get; set; }
// other fields
public override string ToString()
{
return JsonConvert.SerializeObject(this);
}
}
Then put nex...
The idea is to use HttpContext.Response.OnStarting callback, as this is the last event that is fired before the headers are sent. Add the following to your middleware Invoke method.
public async Task Invoke(HttpContext context)
{
context.Response.OnStarting((state) =>
{
if ...
A shell script is a very versatile way to extend your build to basically anything you can think of.
As an exmaple, here is a simple script to compile protobuf files and add the result java files to the source directory for further compilation:
def compilePb() {
exec {
// NOTICE: grad...
With the rgdal package it is possible to import and export shapfiles with R.
The function readOGR can be used to imports shapfiles. If you want to import a file from e.g. ArcGIS the first argument dsn is the path to the folder which contains the shapefile. layer is the name of the shapefile without...
The packages foreign and haven can be used to import and export files from a variety of other statistical packages like Stata, SPSS and SAS and related software. There is a read function for each of the supported data types to import the files.
# loading the packages
library(foreign)
library(have...
The following prints the message Hello, World! to console
public void hello() {
Observable.just("Hello, World!") // create new observable
.subscribe(new Action1<String>() { // subscribe and perform action
@Override
public void call(String st) {
Sy...
The core concepts of RxJava are its Observables and Subscribers. An Observable emits objects, while a Subscriber consumes them.
Observable
Observable is a class that implements the reactive design pattern. These Observables provide methods that allow consumers to subscribe to event changes. The ev...
DELETE FROM `table_name` WHERE `field_one` = 'value_one'
This will delete all rows from the table where the contents of the field_one for that row match 'value_one'
The WHERE clause works in the same way as a select, so things like >, <, <> or LIKE can be used.
Notice: It is necessa...
DELETE FROM table_name ;
This will delete everything, all rows from the table. It is the most basic example of the syntax. It also shows that DELETE statements should really be used with extra care as they may empty a table, if the WHERE clause is omitted.
DELETE FROM `table_name` WHERE `field_one` = 'value_one' LIMIT 1
This works in the same way as the 'Delete with Where clause' example, but it will stop the deletion once the limited number of rows have been removed.
If you are limiting rows for deletion like this, be aware that it will delete th...
CommandDescription<C-w>Delete word before cursor<C-t>Indent current line with by one shiftwidth<C-d>Unindent current line with by one shiftwidth<C-f>reindent the line, (move cursor to auto indent position)<C-a>Insert previously inserted text<C-e>Insert the charact...
An unnamed namespace can be used to ensure names have internal linkage (can only be referred to by the current translation unit). Such a namespace is defined in the same way as any other namespace, but without the name:
namespace {
int foo = 42;
}
foo is only visible in the translation uni...
In C#, there are two different kinds of equality: reference equality and value equality. Value equality is the commonly understood meaning of equality: it means that two objects contain the same values. For example, two integers with the value of 2 have value equality. Reference equality means that ...
There are few approaches available there:
You can subscribe for keyboard appearance events notifications and change offset manually:
//Swift 2.0+
override func viewDidLoad() {
super.viewDidLoad()
NSNotificationCenter.defaultCenter().addObserver(self, selector: #selector(YourVCClas...
The model is named using the class naming convention of unbroken MixedCase and is always the singular of the table name.
For Example: If a table was named orders, the associated model would be named Order
For Example: If a table was named posts, the associated model would be named Post
Rails will...