google-site-verification=EmVnnySXehAfTr_j8ZJN48hwvxJtfNf80pkPX1ObQlA Fast Track News: February 2024

51 BigQuery: Qwik Start - Command Line

 curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/BigQuery%20Qwik%20Start%20%20Command%20Line/quicklabgsp071.sh


sudo chmod +x quicklabgsp071.sh


./quicklabgsp071.sh




Run this task command once you get a score of previous tasks


Task 7. Clean up

Run the bq rm command to remove the babynames dataset with the -r flag to delete all tables in the dataset:


bq rm -r babynames


Confirm the delete command by typing Y.

50 Creating a Looker Modeled Query and Working with Quick Start

 



connection: "bigquery_public_data_looker"


# include all the views

include: "/views/*.view"

include: "/z_tests/*.lkml"

include: "/**/*.dashboard"


datagroup: training_ecommerce_default_datagroup {

  # sql_trigger: SELECT MAX(id) FROM etl_log;;

  max_cache_age: "1 hour"

}


persist_with: training_ecommerce_default_datagroup


label: "E-Commerce Training"


explore: order_items {

  join: users {

    type: left_outer

    sql_on: ${order_items.user_id} = ${users.id} ;;

    relationship: many_to_one

  }


  join: inventory_items {

    type: left_outer

    sql_on: ${order_items.inventory_item_id} = ${inventory_items.id} ;;

    relationship: many_to_one

  }


  join: products {

    type: left_outer

    sql_on: ${inventory_items.product_id} = ${products.id} ;;

    relationship: many_to_one

  }


  join: distribution_centers {

    type: left_outer

    sql_on: ${products.distribution_center_id} = ${distribution_centers.id} ;;

    relationship: many_to_one

  }

}


# Place in `training_ecommerce` model

explore: +order_items {

  query: start_from_here{

      dimensions: [products.department, users.state]

      measures: [order_count, users.count]

      filters: [users.country: "USA"]

    }

}



explore: events {

  join: event_session_facts {

    type: left_outer

    sql_on: ${events.session_id} = ${event_session_facts.session_id} ;;

    relationship: many_to_one

  }

  join: event_session_funnel {

    type: left_outer

    sql_on: ${events.session_id} = ${event_session_funnel.session_id} ;;

    relationship: many_to_one

  }

  join: users {

    type: left_outer

    sql_on: ${events.user_id} = ${users.id} ;;

    relationship: many_to_one

  }

}


48 Eventarc for Cloud Run

 

Eventarc for Cloud Run [GSP773]

Please like share & subscribe to My QwikLab

export REGION=
gcloud config set project $DEVSHELL_PROJECT_ID
gcloud config set run/region $REGION
gcloud config set run/platform managed
gcloud config set eventarc/location $REGION

export PROJECT_NUMBER="$(gcloud projects list --filter=$(gcloud config get-value project) --format='value(PROJECT_NUMBER)')"

gcloud projects add-iam-policy-binding $(gcloud config get-value project) --member=serviceAccount:${PROJECT_NUMBER}-compute@developer.gserviceaccount.com --role='roles/eventarc.admin'

gcloud beta eventarc attributes types list

gcloud beta eventarc attributes types describe \
  google.cloud.pubsub.topic.v1.messagePublished

export SERVICE_NAME=event-display
export IMAGE_NAME="gcr.io/cloudrun/hello"

gcloud run deploy ${SERVICE_NAME} --image ${IMAGE_NAME} --allow-unauthenticated --max-instances=3

gcloud beta eventarc attributes types describe \
  google.cloud.pubsub.topic.v1.messagePublished

gcloud beta eventarc triggers create trigger-pubsub --destination-run-service=${SERVICE_NAME} --matching-criteria="type=google.cloud.pubsub.topic.v1.messagePublished"

export TOPIC_ID=$(gcloud eventarc triggers describe trigger-pubsub --format='value(transport.pubsub.topic)')

gcloud eventarc triggers list

gcloud pubsub topics publish ${TOPIC_ID} --message="Hello there"

Go to Task 5 check the progress

gcloud eventarc triggers delete trigger-pubsub

export BUCKET_NAME=$(gcloud config get-value project)-cr-bucket

gsutil mb -p $(gcloud config get-value project) \
  -l $(gcloud config get-value run/region) \
  gs://${BUCKET_NAME}/

NOTE: Go to IAM & Admin > Audit Logs

  • In the list of services, check the box for Google Cloud Storage.

  • On the right hand side, click the LOG TYPE tab. Admin Write is selected by default,

  • Make sure you also selected to all this three:

Admin Read

Data Read

Data Write

Click Save.

echo "Hello World" > random.txt

gsutil cp random.txt gs://${BUCKET_NAME}/random.txt

gcloud beta eventarc attributes types describe google.cloud.audit.log.v1.written

gcloud beta eventarc triggers create trigger-auditlog --destination-run-service=${SERVICE_NAME} --matching-criteria="type=google.cloud.audit.log.v1.written" --matching-criteria="serviceName=storage.googleapis.com" --matching-criteria="methodName=storage.objects.create" --service-account=${PROJECT_NUMBER}-compute@developer.gserviceaccount.com

gcloud eventarc triggers list

gsutil cp random.txt gs://${BUCKET_NAME}/random.txt

Congratulations, you're all done with the lab 😄

Thanks for watching :)

45 Implement Private Google Access and Cloud NAT

 export ZONE=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Implement%20Private%20Google%20Access%20and%20Cloud%20NAT/quicklab.sh


sudo chmod +x quicklab.sh


./quicklab.sh

44 VPC Networks - Controlling Access

 export ZONE=


curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/VPC%20Networks%20%20Controlling%20Access/quicklabgsp213.sh



sudo chmod +x quicklabgsp213.sh


./quicklabgsp213.sh

41 Google Cloud Fundamentals: Getting Started with Cloud Storage and Cloud SQL

 export ZONE=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Google%20Cloud%20Fundamentals%20Getting%20Started%20with%20Cloud%20Storage%20and%20Cloud%20SQL/quicklab.sh


sudo chmod +x quicklab.sh


./quicklab.sh

40 Getting Started with VPC Networking and Google Compute Engine

 export ZONE_1=


export ZONE_2=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Getting%20Started%20with%20VPC%20Networking%20and%20Google%20Compute%20Engine%20%20Windows/quicklab.sh


sudo chmod +x quicklab.sh


./quicklab.sh

38 Automating the Deployment of Infrastructure Using Terraform

 export ZONE=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Automating%20the%20Deployment%20of%20Infrastructure%20Using%20Terraform/quicklab.sh


sudo chmod +x quicklab.sh


./quicklab.sh

37 Exploring Your Ecommerce Dataset with SQL in Google BigQuery

 curl -LO github.com/quiccklabs/Labs_solutions/raw/master/Exploring%20Your%20Ecommerce%20Dataset%20with%20SQL%20in%20Google%20BigQuery/quicklabgsp407.sh



sudo chmod +x quicklabgsp407.sh


./quicklabgsp407.sh

36 Movie Recommendations in BigQuery ML 2.5

 curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Movie%20Recommendations%20in%20BigQuery%20ML%2025/quicklab.sh


sudo chmod +x quicklab.sh


./quicklab.sh

35 Predict Bike Trip Duration with a Regression Model in BQML 2.5

 curl -LO raw.githubusercontent.com/Techcps/GSP-Short-Trick/master/Predict%20Bike%20Trip%20Duration%20with%20a%20Regression%20Model%20in%20BQML%202.5/techcps.sh

sudo chmod +x techcps.sh

./techcps.sh

32 Optimizing your BigQuery Queries for Performance 2.5

 curl -LO raw.githubusercontent.com/Techcps/GSP-Short-Trick/master/Optimizing%20your%20BigQuery%20Queries%20for%20Performance%202.5/techcps.sh

sudo chmod +x techcps.sh

./techcps.sh

31 Cloud Storage

 Run on Project ID-1



export ZONE=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Cloud%20Storage/task1.sh


sudo chmod +x task1.sh


./task1.sh



Run on Project ID-2



export ZONE=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Cloud%20Storage/task2.sh


sudo chmod +x task2.sh


./task2.sh

30 Exploring IAM

 export USER_2=


export ZONE=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Exploring%20IAM/quicklab.sh



sudo chmod +x quicklab.sh


./quicklab.sh

Working with Virtual Machines

export ZONE=


curl -LO raw.githubusercontent.com/QUICK-GCP-LAB/2-Minutes-Labs-Solutions/main/Working%20with%20Virtual%20Machines/VM.sh


sudo chmod +x VM.sh


./VM.sh 

Implement Private Google Access and Cloud NAT

export ZONE=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Implement%20Private%20Google%20Access%20and%20Cloud%20NAT/quicklab.sh


sudo chmod +x quicklab.sh


./quicklab.sh 

GSP001 Creating a Virtual Machine

export ZONE=

curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/d51b46a30325298b314a3c2f90624909dfcd5014/Creating%20a%20Virtual%20Machine/quicklabgsp001.sh


sudo chmod +x quicklabgsp001.sh

./quicklabgsp001.sh

VPC Networking

 export ZONE_1=


export ZONE_2=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/VPC%20Networking/quicklab.sh


sudo chmod +x quicklab.sh


./quicklab.sh

Introduction to programming in C Week4 Programming

 Question1:

#include <stdio.h> int main() { int n; scanf("%d", &n); int arr[n]; for (int i = 0; i < n; i++) { scanf("%d", &arr[i]); } // Calculate the mean of the array int sum = 0; for (int i = 0; i < n; i++) { sum += arr[i]; } float mean = (float)sum / n; // Calculate the sum of elements above the mean int sum_above_mean = 0; for (int i = 0; i < n; i++) { if (arr[i] >= mean) { sum_above_mean += arr[i]; } } printf("%d", sum_above_mean); return 0; } Question2: #include <stdio.h> int main() { int n1, n2; scanf("%d", &n1); int arr1[n1]; for (int i = 0; i < n1; i++) { scanf("%d", &arr1[i]); } scanf("%d", &n2); int arr2[n2]; for (int i = 0; i < n2; i++) { scanf("%d", &arr2[i]); } int smallest = -1; for (int i = 0; i < n1; i++) { for (int j = 0; j < n2; j++) { if (arr1[i] == arr2[j]) { if (smallest == -1 || arr1[i] < smallest) { smallest = arr1[i]; } } } } printf("%d", smallest); return 0; } Question3: #include <stdio.h> #include <string.h> // Function to check if two strings are anagrams int areAnagrams(char str1[], char str2[]) { int len1 = strlen(str1); int len2 = strlen(str2); // If lengths are different, they can't be anagrams if (len1 != len2) { return 0; } // Count characters in both strings int count1[26] = {0}; int count2[26] = {0}; for (int i = 0; i < len1; i++) { count1[str1[i] - 'A']++; count2[str2[i] - 'A']++; } // Check if counts of characters are same for (int i = 0; i < 26; i++) { if (count1[i] != count2[i]) { return 0; } } return 1; // Strings are anagrams } int main() { int size; scanf("%d", &size); char str1[21], str2[21]; scanf("%s", str1); scanf("%s", str2); if (areAnagrams(str1, str2)) { printf("1"); } else { printf("0"); } return 0; }

Implementing Least Privilege IAM Policy Bindings in Cloud Run [APPRUN]

 export LOCATION=


curl -LO raw.githubusercontent.com/Techcps/GSP-Short-Trick/master/Implementing%20Least%20Privilege%20IAM%20Policy%20Bindings%20in%20Cloud%20Run%20%5BAPPRUN%5D/techcpslab.sh

sudo chmod +x techcpslab.sh

./techcpslab.sh

GSP315 Perform Foundational Infrastructure Tasks in Google Cloud: Challenge Lab


============================================================================================================================



export USERNAME2=


export ZONE=


export FUNCTION_NAME=


export TOPIC_NAME=



curl -LO raw.githubusercontent.com/quiccklabs/Labs_solutions/master/Perform%20Foundational%20Infrastructure%20Tasks%20in%20Google%20Cloud%20Challenge%20Lab/quicklabgsp315.sh


sudo chmod +x quicklabgsp315.sh


./quicklabgsp315.sh




======================================================================================================================== 

GSP096 Google Cloud Pub/Sub: Qwik Start - Console

gcloud pubsub topics create myTopic


gcloud  pubsub subscriptions create --topic myTopic MySub 

GSP081 Cloud Functions: Qwik Start - Console

 REGION=



gcloud services enable run.googleapis.com

export PROJECT_ID=$(gcloud config list --format 'value(core.project)')

gcloud config set compute/region $REGION


mkdir ~/hello-https && cd $_

touch index.js && touch package.json


tee -a index.js <<EOF

/**

 * Responds to any HTTP request.

 *

 * @param {!express:Request} req HTTP request context.

 * @param {!express:Response} res HTTP response context.

 */

exports.helloWorld = (req, res) => {

  let message = req.query.message || req.body.message || 'Hello World!';

  res.status(200).send(message);

};

EOF



tee -a package.json <<EOF

{

  "name": "sample-http",

  "version": "0.0.1"

}

EOF




gcloud functions deploy GCFunction \

  --gen2 \

  --runtime nodejs18 \

  --entry-point helloWorld \

  --source . \

  --region $REGION \

  --trigger-http \

  --timeout 540s \

  --allow-unauthenticated \

  --max-instances 5



#-----------------IF YOU SEE ERROR > WAIT FOR 5 MINUTES > AND RERUN ABOVE COMMAND "gcloud functions deploy ..." ------------------


URL=https://$REGION-$PROJECT_ID.cloudfunctions.net/GCFunction

echo $URL


curl -m 70 -X POST $URL \

    -H "Authorization: bearer $(gcloud auth print-identity-token)" \

    -H "Content-Type: application/json" \

    -d '{"message":"Hello World!"}'


April Week 2 || Lab 2 || Troubleshooting Data Models in Looker

  CREATE NEW FILE NAME: user_order_lifetime view: user_order_lifetime { derived_table: { sql: SELECT order_items.user_id as us...