props are used to pass data and methods from a parent component to a child component.
Interesting things about props
They are immutable.
They allow us to create reusable components.
Basic example
class Parent extends React.Component{
doSomething(){
console.log("Parent comp...
When a React component is created, a number of functions are called:
If you are using React.createClass (ES5), 5 user defined functions are called
If you are using class Component extends React.Component (ES6), 3 user defined functions are called
getDefaultProps() (ES5 only)
This is the firs...
When you install Oracle 11g or 12cR1, an older version of Apex is pre-installed. It is highly recommended to upgrade it to the latest version.
Go to apex.oracle.com and download the latest version of Apex.
Follow the documentation for the specific version to install it.
Important Docu...
strsplit is a useful function for breaking up a vector into an list on some character pattern. With typical R tools, the whole list can be reincorporated to a data.frame or part of the list might be used in a graphing exercise.
Here is a common usage of strsplit: break a character vector along a co...
Haskell has list comprehensions, which are a lot like set comprehensions in math and similar implementations in imperative languages such as Python and JavaScript. At their most basic, list comprehensions take the following form.
[ x | x <- someList ]
For example
[ x | x <- [1..4] ] -...
See this Q&A question if you don't know what race conditions are.
The following code may be subject to race conditions :
article = Article.objects.get(pk=69)
article.views_count += 1
article.save()
If views_count is equal to 1337, this will result in such query:
UPDATE app_article SET vi...
Transactions can be used to make multiple changes to the database atomically. Any normal transaction follows this pattern:
// You need a writable database to perform transactions
final SQLiteDatabase database = openHelper.getWritableDatabase();
// This call starts a transaction
database.beginT...
Orders Table
CustomerIdProductIdQuantityPrice12510013220014150021450356700
To check for customers who have ordered both - ProductID 2 and 3, HAVING can be used
select customerId
from orders
where productID in (2,3)
group by customerId
having count(distinct productID) = 2
Return value:...
Some basic types and classes in Java are fundamentally mutable. For example, all array types are mutable, and so are classes like java.util.Data. This can be awkward in situations where an immutable type is mandated.
One way to deal with this is to create an immutable wrapper for the mutable type...
You can let I18n handle pluralization for you, just use count argument.
You need to set up your locale file like this:
# config/locales/en.yml
en:
online_users:
one: "1 user is online"
other: "%{count} users are online"
And then use the key you just created by ...
Specially useful for has_and_belongs_to_many relation, you can manually create a join table using the create_table method.
Suppose you have two models Tags and Proyects, and you'd like to associate them using a has_and_belongs_to_many relation. You need a join table to associate instances of both c...
Position configuration for the credits label. Supported properties are align, verticalAlign, x and y.
Defaults to:
credits: {
position: {
align: 'right',
x: -10,
verticalAlign: 'bottom',
y: -5
}
},
When we are finished querying the database, it is recommended to close the connection to free up resources.
Object oriented style
$conn->close();
Procedural style
mysqli_close($conn);
Note: The connection to the server will be closed as soon as the execution of the script ends, unless it...
The return statement in Bash doesn't return a value like C-functions, instead it exits the function with a return status. You can think of it as the exit status of that function.
If you want to return a value from the function then send the value to stdout like this:
fun() {
local var="S...
The DATEDIF function returns the difference between two date values, based on the interval specified. It is provided for compatibility with Lotus 1-2-3. The DATEDIF function cannot be found on the function list and autocomplete and screen tips are unavailable. Note: It is pronounced "date diff&...
Some example cases when the result is an optional.
var result: AnyObject? = someMethod()
switch result {
case nil:
print("result is nothing")
case is String:
print("result is a String")
case _ as Double:
print("result is not nil, any value that is a Dou...
Before C++17, having pointers with a value of nullptr commonly represented the absence of a value. This is a good solution for large objects that have been dynamically allocated and are already managed by pointers. However, this solution does not work well for small or primitive types such as int, w...
Before C++17, a function typically represented failure in one of several ways:
A null pointer was returned.
e.g. Calling a function Delegate *App::get_delegate() on an App instance that did not have a delegate would return nullptr.
This is a good solution for objects that have been dynamicall...
This illustrates that union members shares memory and that struct members does not share memory.
#include <stdio.h>
#include <string.h>
union My_Union
{
int variable_1;
int variable_2;
};
struct My_Struct
{
int variable_1;
int variable_2;
};
int main (void)
{
...