After receiving the arguments, you can print them as follows:
int main(int argc, char **argv)
{
for (int i = 1; i < argc; i++)
{
printf("Argument %d: [%s]\n", i, argv[i]);
}
}
Notes
The argv parameter can be also defined as char *argv[].
argv[0] may co...
The function map() from the package maps provides a simple starting point for creating maps with R.
A basic world map can be drawn as follows:
require(maps)
map()
The color of the outline can be changed by setting the color parameter, col, to either the character name or hex value of a color...
Although it is possible to create a fragment constructor with parameters, Android internally calls the zero-argument constructor when recreating fragments (for example, if they are being restored after being killed for Android's own reasons). For this reason, it is not advisable to rely on a constru...
Each enum class contains an implicit static method named values(). This method returns an array containing all values of that enum. You can use this method to iterate over the values. It is important to note however that this method returns a new array every time it is called.
public enum Day {
...
The android:process field defines the name of the process where the service is to run. Normally, all components of an application run in the default process created for the application. However, a component can override the default with its own process attribute, allowing you to spread your applicat...
You may pull (download) files from the device by executing the following command:
adb pull <remote> <local>
For example:
adb pull /sdcard/ ~/
You may also push (upload) files from your computer to the device:
adb push <local> <remote>
For example:
adb push ~/im...
Abstract classes are classes that are meant to be inherited but avoid implementing specific methods, leaving behind only method signatures that subclasses must implement.
Abstract classes are useful for defining and enforcing class abstractions at a high level, similar to the concept of interfaces ...
Since Git 1.7.12 it is possible to rebase down to the root commit. The root commit is the first commit ever made in a repository, and normally cannot be edited. Use the following command:
git rebase -i --root
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"...
TRUNCATE TABLE Employee;
Using truncate table is often better then using DELETE TABLE as it ignores all the indexes and triggers and just removes everything.
Delete table is a row based operation this means that each row is deleted. Truncate table is a data page operation the entire data page is...
This code selects data out of a table and displays it in the query tool (usually SSMS)
SELECT Column1, Column2, Column3 FROM MySourceTable;
This code inserts that data into a table:
INSERT INTO MyTargetTable (Column1, Column2, Column3)
SELECT Column1, Column2, Column3 FROM MySourceTable;
This code selects data out of a table:
SELECT Column1, Column2, Column3 FROM MySourceTable;
This code creates a new table called MyNewTable and puts that data into it
SELECT Column1, Column2, Column3
INTO MyNewTable
FROM MySourceTable;
The display CSS property is fundamental for controlling the layout and flow of an HTML document. Most elements have a default display value of either block or inline (though some elements have other default values).
Inline
An inline element occupies only as much width as necessary. It stacks horiz...
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...
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...
Java-like enumerations can be created by extending Enumeration.
object WeekDays extends Enumeration {
val Mon, Tue, Wed, Thu, Fri, Sat, Sun = Value
}
def isWeekend(day: WeekDays.Value): Boolean = day match {
case WeekDays.Sat | WeekDays.Sun => true
case _ => false
}
isWeekend...
<?php
namespace models;
use yii\db\ActiveRecord;
use yii\behaviors\TimestampBehavior;
class Post extends ActiveRecord
{
public static function tableName()
{
return 'post';
}
public function rules() {
...
The following will list up to ten of the most recently modified files in the current directory, using a long listing format (-l) and sorted by time (-t).
ls -lt | head
The random number generator can (and should) be used for multiple distributions.
#include <iostream>
#include <random>
int main()
{
std::default_random_engine pseudo_random_generator;
std::uniform_int_distribution<int> int_distribution(0, 9);
std::uniform_real_dis...