!! suffixes ignore nullability and returns a non-null version of that type. KotlinNullPointerException will be thrown if the object is a null.
val message: String? = null
println(message!!) //KotlinNullPointerException thrown, app crashes
getTimeStemp is a unix representation of a datetime object.
$date = new DateTime();
echo $date->getTimestamp();
this will out put an integer indication the seconds that have elapsed since 00:00:00 UTC, Thursday, 1 January 1970.
setDate sets the date in a DateTime object.
$date = new DateTime();
$date->setDate(2016, 7, 25);
this example sets the date to be the twenty-fifth of July, 2015, it will produce the following result:
2016-07-25 17:52:15.819442
The & character appears first in entity references and must be escaped in element content or in attribute content.
<?xml version="1.0"?>
<document attribute="An ampersand is escaped as &amp;">
An ampersand can also be escaped as &amp; in element conte...
The < character appears first in entity tags and must be escaped in element content or in attribute content.
<?xml version="1.0"?>
<document attribute="A lower-than sign is escaped as &lt;">
2 + 2 &lt; 5
</document>
The ]]> character sequence is not allowed in element content. The easiest way to escape it is to escape > as &gt;.
<?xml version="1.0"?>
<document>
The sequence ]]&gt; cannot appear in element content.
</document>
Attribute values can appear in simple or double quotes. The appropriate character must be escaped.
<?xml version="1.0"?>
<document
quot-attribute="This is a &quot;double quote&quot; and this one is 'simple'"
apos-attribute='This is a &apos;simple quot...
Longer portions of text containing special characters can be escaped with a CDATA section. CDATA sections can only appear in element content.
<?xml version="1.0"?>
<document>
This is a CDATA section : <![CDATA[ plenty of special characters like & < > " ; ...
Characters can be escaped using character references, in element content or attribute values. Their Unicode codepoint can be specified in decimal or hex.
<?xml version="1.0"?>
<document>
The line feed character can be escaped with a decimal (&#10;) or hex (&#xA;)
...
Type abbreviations allow you to create aliases on existing types to give them a more meaningful senses.
// Name is an alias for a string
type Name = string
// PhoneNumber is an alias for a string
type PhoneNumber = string
Then you can use the alias just as any other type:
// Create a recor...
This is a specialized field, used to store binary data. It only accepts bytes. Data is base64 serialized upon storage.
As this is storing binary data, this field cannot be used in a filter.
from django.db import models
class MyModel(models.Model):
my_binary_data = models.BinaryField()
...
In real world, connection and server delays could occur, to simulate delays in development environment Meteor._sleepForMs(ms); could be used
Meteor.publish('USER_DATA', function() {
Meteor._sleepForMs(3000); // Simulate 3 seconds delay
return Meteor.users.find({});
});
select '123' * 2;
To make the multiplication with 2 MySQL automatically converts the string 123 into a number.
Return value:
246
The conversion to a number starts from left to right. If the conversion is not possible the result is 0
select '123ABC' * 2
Return value:
246
select 'A...
To load an image and place it on the canvas
var image = new Image(); // see note on creating an image
image.src = "imageURL";
image.onload = function(){
ctx.drawImage(this,0,0);
}
Creating an image
There are several ways to create an image
new Image()
document.createEleme...
What's an image sprite?
An image sprite is a single asset located within an image sprite sheet.
An image sprite sheet is an image file that contains more than one asset that can be extracted from it.
For example:
The image above is an image sprite sheet, and each one of those stars is a sprite...
@Entity
class Note {
@Id
Integer id;
@Basic
String note;
@Basic
int count;
}
Getters, setters etc. are ommitted for brevity, but they are not needed for JPA anyway.
This Java class would map to the following table (depending on your database, here given in on...
@Entity
class Note {
@Id
Integer id;
@Basic
String note;
@Transient
String parsedNote;
String readParsedNote() {
if (parsedNote == null) { /* initialize from note */ }
return parsedNote;
}
}
If your class needs fields that should ...
Suppose we want to get all product categories with total sales greater than 20.
Here is a query without Common Table Expressions:
SELECT category.description, sum(product.price) as total_sales
FROM sale
LEFT JOIN product on sale.product_id = product.id
LEFT JOIN category on product.category_id ...
Suppose we want to query the "cheapest products" from the "top categories".
Here is an example of query using Common Table Expressions
-- all_sales: just a simple SELECT with all the needed JOINS
WITH all_sales AS (
SELECT
product.price as product_price,
category.id a...