View machine-learning.md

Machine Learning APIs by example: an API call to rule them all

Think your business could make use of Google's machine learning expertise when it comes to powering and improving your business applications, but do you get stuck on building and training your own custom model? While a few cloud providers offer pre-trained models, Google Cloud Platform (GCP) offers five APIs: Google Cloud Vision API, Cloud Speech API, Cloud Natural Language API, Cloud Translation API and Cloud Video API. In this session you will see how with a single API call you can enrich your application through code and live demo.

View add_speed_to_laps_table.sql
-- Virtual Column
ALTER TABLE `laps`
ADD COLUMN speed DOUBLE
GENERATED ALWAYS
AS (`distance` / `time`);
-- Stored Column
ALTER TABLE `laps`
ADD COLUMN speed DOUBLE
GENERATED ALWAYS
View laps_table.sql
CREATE TABLE `laps` (
`id` INT(10) NOT NULL AUTO_INCREMENT,
`athlete` VARCHAR(255) NOT NULL,
`distance` INT(10) NOT NULL,
`time` INT(10) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE = InnoDB;
View migration_n_plus_one.rb
class CreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :name
t.timestamps
end
end
end
View add_foreign_key.sql
ALTER TABLE addresses ADD CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) REFERENCES users (`id`);
View n_plus_one.rb
users = User.all
users.each do |user|
puts "Name #{user.name}"
puts "Addresses: "
user.addresses.each do |address|
puts address.street
puts "#{address.city} - #{address.state}"
end
View n_plus_one.txt
2.4.1 :001 > user = User.first
User Load (0.9ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT $1 [["LIMIT", 1]]
=> #<User id: 1, name: "Gabriela", created_at: "2018-02-06 14:25:06", updated_at: "2018-02-06 14:25:06">
2.4.1 :002 > Address.create(street: "111 8th Ave", city: "New York", state: "NY", user: user)
(0.2ms) BEGIN
SQL (1.9ms) INSERT INTO "addresses" ("street", "city", "state", "user_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6) RETURNING "id" [["street", "111 8th Ave"], ["city", "New York"], ["state", "NY"], ["user_id", 1], ["created_at", "2018-02-06 14:28:51.050940"], ["updated_at", "2018-02-06 14:28:51.050940"]]
(5.7ms) COMMIT
=> #<Address id: 1, street: "111 8th Ave", city: "New York", state: "NY", zipcode: nil, user_id: 1, created_at: "2018-02-06 14:28:51", updated_at: "2018-02-06 14:28:51">
2.4.1 :003 > user
=> #<User id: 1, name: "Gabriela", created_at: "2018-02-06 14:25:06", updated_at: "2018-02-06 14:25:06">
View keybase.md

Keybase proof

I hereby claim:

  • I am gabidavila on github.
  • I am gabidavila (https://keybase.io/gabidavila) on keybase.
  • I have a public key whose fingerprint is 9656 6392 F402 856F A447 B80B 2B8E F14E CC27 3FD3

To claim this, I am signing this object:

View division_by_zero.md

MySQL 5.7 doesn't support division by 0 in write operations. However in virtual columns they are allowed, but if you try to update a row that previously had division by zero to another value so not to cause the division by zero you get an error and the row gets immutable.

Create a table trips as the following:

CREATE TABLE trips (
  id         INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
  start_time DATETIME         NOT NULL,
  end_time   DATETIME         NOT NULL,
  distance   INT(10)          NOT NULL DEFAULT 0,
View reverseHalfTime.js
function reverseString(word) {
const new_word = [];
const array_chars = word.split("");
const last_index = array_chars.length - 1;
for (let i = 0; i <= Math.ceil(array_chars.length/2); i++) {
new_word[last_index - i] = array_chars[i];
new_word[i] = array_chars[last_index - i]
}