Skip to content

Instantly share code, notes, and snippets.

View gabidavila's full-sized avatar
💁‍♀️
I try to solve all my problems with a single SQL query.

Gabriela Ferrara gabidavila

💁‍♀️
I try to solve all my problems with a single SQL query.
View GitHub Profile
const mysqlx = require('@mysql/xdevapi');
const options = require('./config')
mysqlx.getSession(options)
.then((session) => {
const db = session.getSchema("worldcup");
let teamsCollection = db.getCollection("teams_2018");
return teamsCollection.find("name = :country1 OR name = :country2")
.bind("country1", "Brazil")
.bind("country2", "England")
[
4,
"Brazil ",
{
"players": [{
"id": 70,
"dob": "05.03.1993",
"club": "FC Shakhtar Donetsk (UKR)",
"name": "FRED",
"height": 169,
const mysqlx = require('@mysql/xdevapi');
const options = require('./config')
mysqlx.getSession(options)
.then((session) => {
const db = session.getSchema("worldcup");
const tableTeams = db.getTable("teams");
return tableTeams;
})
DESCRIBE `users`;
-- +-------------+--------------+------+-----+-------------------+-----------------------------+
-- | Field | Type | Null | Key | Default | Extra |
-- +-------------+--------------+------+-----+-------------------+-----------------------------+
-- | id | int(11) | NO | PRI | NULL | auto_increment |
-- | id_str | varchar(255) | NO | UNI | NULL | |
-- | screen_name | varchar(255) | NO | MUL | NULL | |
-- | response | json | NO | | NULL | |
-- | created_at | datetime | NO | | CURRENT_TIMESTAMP | |

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.

-- 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
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;
class CreateUsers < ActiveRecord::Migration[5.1]
def change
create_table :users do |t|
t.string :name
t.timestamps
end
end
end
ALTER TABLE addresses ADD CONSTRAINT `fk_user_id` FOREIGN KEY (`user_id`) REFERENCES users (`id`);
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