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
# Just a record of how to deploy flask to heroku | |
# original post from https://blog.heron.me/damn-simple-python-web-server-on-heroku-ba67cad2fb18 | |
# 1.Create a new project folder: | |
$ PROJECT=<WHATEVER YOUR PROJECT NAME> | |
$ mkdir $PROJECT && cd $PROJECT | |
# 2.Add requirements.txt inside: | |
Flask==1.0.3 | |
gunicorn==19.9.0 |
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
# pip install qrcode | |
import qrcode | |
img = qrcode.make("http://yourURL.com") | |
img.save("QRcode.png") |
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
from linebot.models import ( | |
MessageEvent, TextMessage, TestSendMessage, StickerMessage, StickerSendMessage, ConfirmTemplate, TemplateSendMessage, MessageAction, URIAction, LocationMessage | |
) | |
### TextSendMessage | |
### StickerSendMessage:只有官方預設的四組貼圖包可以使用 | |
def handle_message(event): |
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
from __future__ import print_function | |
import os | |
import io | |
import time | |
from googleapiclient.discovery import build | |
from googleapiclient.http import MediaFileUpload, MediaIoBaseDownload | |
from httplib2 import Http | |
from oauth2client import file, client, tools | |
# 權限必須 |
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 io | |
import os | |
# Imports the Google Cloud client library | |
from google.cloud import vision | |
from google.cloud.vision import types | |
os.environ["GOOGLE_APPLICATION_CREDENTIALS"]=r"yourPath.json" | |
# Instantiates a client | |
client = vision.ImageAnnotatorClient() |
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
#下載 | |
!wget --content-disposition <url> | |
#解壓縮ZIP | |
!apt-get install unzip | |
!unzip 'filename.zip' -d <path> | |
#解壓縮RAR | |
!apt-get install unrar | |
!unrar e 'filename.rar' |
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 googletrans using pip | |
!pip install googletrans | |
# Importing the necessary libraries | |
import pandas as pd | |
import googletrans | |
from googletrans import Translator | |
# Reading and storing the CSV file as a dataframe | |
df = pd.read_csv('path/to/yourFile.csv') |
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
web_entities { | |
entity_id: "/g/11fs7n3mgw" | |
score: 1.1109451055526733 | |
description: "Jacana Ecological Education Park" | |
} | |
web_entities { | |
entity_id: "/m/029xmf" | |
score: 1.0777499675750732 | |
description: "Pheasant-tailed jacana" | |
} |
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
from tqdm import tqdm | |
import requests as req | |
url = "https://abc.com.tw/123.jpg" | |
def download(url): | |
filename = url.split('/')[-1] #可以觀察其filename的寫法做為參考 | |
r = req.get(url, stream=True) | |
with open(filename, 'wb') as f: | |
for data in tqdm(r.iter_content(1024)): |
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 2018 The TensorFlow Authors. All Rights Reserved. | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, |