Tutorial by Examples: ai

5 The <input type="email"> is used for input fields that should contain an e-mail address. <form> <label>E-mail: <label> <input type="email" name="email"> </form> E-mail address can be automatically validated when submitte...
This is the Python 2 syntax, note the commas , on the raise and except lines: Python 2.x2.3 try: raise IOError, "input/output error" except IOError, exc: print exc In Python 3, the , syntax is dropped and replaced by parenthesis and the as keyword: try: raise IOErro...
Rails uses sqlite3 as the default database, but you can generate a new rails application with a database of your choice. Just add the -d option followed by the name of the database. $ rails new MyApp -T -d postgresql This is a (non-exhaustive) list of available database options: mysql oracle...
// You need a writable database to insert data final SQLiteDatabase database = openHelper.getWritableDatabase(); // Create a ContentValues instance which contains the data for each column // You do not need to specify a value for the PRIMARY KEY column. // Unique values for these are automatic...
To raise an exception use Kernel#raise passing the exception class and/or message: raise StandardError # raises a StandardError.new raise StandardError, "An error" # raises a StandardError.new("An error") You can also simply pass an error message. In this case, the message i...
docker run --restart=always -d <container> By default, Docker will not restart containers when the Docker daemon restarts, for example after a host system reboot. Docker provides a restart policy for your containers by supplying the --restart command line option. Supplying --restart=always ...
Let's say we have an interface for logging: interface Logger { function log($message); } Now say we have two concrete implementations of the Logger interface: the FileLogger and the ConsoleLogger. class FileLogger implements Logger { public function log($message) { // Append...
Arrays are available in most programming languages, often using square [] or round () brackets to access the elements, e.g. Carray[6] or VBarray(6).
ALTER TABLE Employees DROP CONSTRAINT DefaultSalary This Drops a constraint called DefaultSalary from the employees table definition. Note:- Ensure that constraints of the column are dropped before dropping a column.
ALTER TABLE Employees ADD CONSTRAINT DefaultSalary DEFAULT ((100)) FOR [Salary] This adds a constraint called DefaultSalary which specifies a default of 100 for the Salary column. A constraint can be added at the table level. Types of constraints Primary Key - prevents a duplicate record in...
To keep a container running in the background, supply the -d command line option during container startup: docker run -d busybox top The option -d runs the container in detached mode. It is also equivalent to -d=true. A container in detached mode cannot be removed automatically when it stops, t...
A Docker volume is a file or directory which persists beyond the lifetime of the container. It is possible to mount a host file or directory into a container as a volume (bypassing the UnionFS). Add a volume with the -v command line option: docker run -d -v "/data" awesome/app bootstrap....
You can use traits to modify methods of a class, using traits in stackable fashion. The following example shows how traits can be stacked. The ordering of the traits are important. Using different order of traits, different behavior is achieved. class Ball { def roll(ball : String) = println(&q...
To find out the IP address of your container, use: docker inspect <container id> | grep IPAddress or use docker inspect docker inspect --format '{{ .NetworkSettings.IPAddress }}' ${CID}
cmd := exec.Command("sleep", "5") // Does not wait for command to complete before returning err := cmd.Start() if err != nil { log.Fatal(err) } // Wait for cmd to Return err = cmd.Wait() log.Printf("Command finished with error: %v", err)
This will delete all rows that match the WHERE criteria. DELETE FROM Employees WHERE FName = 'John'
When pattern matching an object whose type is a sealed trait, Scala will check at compile-time that all cases are 'exhaustively matched': sealed trait Shape case class Square(height: Int, width: Int) extends Shape case class Circle(radius: Int) extends Shape case object Point extends Shape ...
5.0 In PowerShell 5.0+ you can list available constructors by calling the static new-method without parentheses. PS> [DateTime]::new OverloadDefinitions ------------------- datetime new(long ticks) datetime new(long ticks, System.DateTimeKind kind) datetime new(int year, int month, int d...
Pipes may be chained. <p>Today is {{ today | date:'fullDate' | uppercase}}.</p>
C++11 One of constraining function is to use trailing decltype to specify the return type: namespace details { using std::to_string; // this one is constrained on being able to call to_string(T) template <class T> auto convert_to_string(T const& val, int ) ->...

Page 5 of 47