This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Comprehensive ----- | |
strings = ['a', 'as', 'bat', 'car', 'dove', 'python'] | |
[x.upper() for x in strings if len(x) > 2] ## list comprehensive | |
{x.upper() for x in strings if len(x) > 2} ## set comprehensive | |
{key: val.upper() for key,val in enumerate(strings)} ## dict comprehensive | |
## Nested Comprehensive ---- | |
all_data = [['John', 'Emily', 'Michael', 'Mary', 'Steven'], | |
['Maria', 'Juan', 'Javier', 'Natalia', 'Pilar', 'Eerin']] | |
## full |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Install this in terminal: !pip install --upgrade google-api-python-client | |
## This func to call googleapi, apply the face_detection on img, and output the happy/unhappy likelihood | |
def detect_joy(IMG): | |
from googleapiclient.discovery import build | |
vservice = build('vision', 'v1', developerKey=APIKEY) | |
## CHECK THIS: https://cloud.google.com/vision/docs/reference/rest/v1/images/annotate | |
## The have the interactive tool to create the body of request | |
request = vservice.images().annotate(body={ | |
"requests": [ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Import modules | |
import pandas as pd | |
import numpy as np | |
import scipy as sp | |
import pandas_datareader.data as web | |
from datetime import datetime as dt ## datetime | |
import json ## json | |
import requests ## API | |
from lxml import objectify | |
import os |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pwd | |
ls | |
gcloud config list | |
gsutil ls | |
gsutil ls gs://storage-lab-console/ | |
gsutil ls gs://storage-lab-console/** | |
gsutil mb --help |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
gcloud config get-value project | |
gcloud compute instances list | |
gcloud services list | |
gcloud services list -h | |
gcloud services list --enabled | |
gcloud services list --available | |
gcloud services list --available | grep compute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
On the system that has access to internet | |
The pip download command lets you download packages without installing them: | |
pip download -r requirements.txt | |
(In previous versions of pip, this was spelled pip install --download -r requirements.txt.) | |
On the system that has no access to internet | |
Then you can use |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo apt-get -y update | |
sudo apt-get -y install \ | |
ca-certificates \ | |
curl \ | |
gnupg \ | |
lsb-release | |
sudo mkdir -p /etc/apt/keyrings | |
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright (c) Jupyter Development Team. | |
# Distributed under the terms of the Modified BSD License. | |
ARG OWNER=jupyter | |
ARG BASE_CONTAINER=$OWNER/scipy-notebook | |
FROM $BASE_CONTAINER | |
LABEL maintainer="Jupyter Project <jupyter@googlegroups.com>" | |
# Fix DL4006 | |
SHELL ["/bin/bash", "-o", "pipefail", "-c"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
print(os.environ['HOME']) | |
#To see a list of all environment variables: | |
print(os.environ) | |
# Returns `None` if key doesn't exist | |
print(os.environ.get('KEY_THAT_MIGHT_EXIST')) | |
# Returns `default_value` if key doesn't exist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
curl -s https://packagecloud.io/install/repositories/github/git-lfs/script.rpm.sh | sudo bash | |
sudo yum install git-lfs -y | |
git lfs install |