Multi-Column Primary Key in MySQL 5

Quoted from the CREATE TABLE Syntax page: A PRIMARY KEY can be a multiple-column index. However, you cannot create a multiple-column index using the PRIMARY KEY key attribute in a column specification. Doing so only marks that single column as primary. You must use a separate PRIMARY KEY(index_col_name, …) clause. Something like this can be … Read more

‘MyhomePage({Key key, this.title}) : super(key: key);’ in Flutter – what would be a clear explanation with an example?

The code is the constructor of the MyHomepage widget. {Key key, this.title} It declares two optional named parameters (optional named because of {}) where the first is of name key with type Key the second is of name title with the type of the field this.title and automatically initializes this.title with the passed value. This … Read more

Converting nested hash keys from CamelCase to snake_case in Ruby

If you use Rails: Example with hash: camelCase to snake_case: hash = { camelCase: ‘value1’, changeMe: ‘value2’ } hash.transform_keys { |key| key.to_s.underscore } # => { “camel_case” => “value1”, “change_me” => “value2” } source: http://apidock.com/rails/v4.0.2/Hash/transform_keys For nested attributes use deep_transform_keys instead of transform_keys, example: hash = { camelCase: ‘value1’, changeMe: { hereToo: { andMe: ‘thanks’ … Read more

Difference between onKey(), OnKeyDown() and dispatchKeyEvent() methods provided by Android?

Tracing the source code of the 5.1 Source for the View Class. It would seem that dispatchKeyEvent() is the first method called by the system. Overloading it will prevent any and all key events from being called unless the base version is called. dispatchKeyEvent()‘s first move is to attempt to pass the event to an … Read more