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
def image_to_object_localization( | |
project_id, sub_name, duration, binary, cloud_region, registry_id, | |
device_id): | |
import base64 | |
import binascii | |
import io | |
import time | |
from google.cloud import pubsub | |
from google.cloud import vision |
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
def draw_obj(image_file, text, vects): | |
"""Draw a border around the image using the label and vector list.""" | |
from PIL import Image, ImageDraw, ImageFont | |
im = Image.open(image_file) | |
w = im.width | |
h = im.height | |
draw = ImageDraw.Draw(im) | |
fnt = ImageFont.truetype('Verdana.ttf', 40) | |
draw.text( |
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
def receive_image(project_id, sub_name, prefix, extension, duration, binary): | |
"""Receieve images transmitted to a PubSub subscription.""" | |
import base64 | |
import binascii | |
import io | |
import time | |
from google.cloud import pubsub | |
from PIL import Image |
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
// Replace the variables in this block with real values. | |
var address = '<your-server-ip-address>'; | |
var user = 'root'; | |
var userPwd = '<your-password>'; | |
var db = '<your-db-name>'; | |
var dbUrl = 'jdbc:mysql://' + address + '/' + db; | |
// Read up to 1000 rows of data from the table and log them. | |
function readFromTable() { |
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
/* | |
* Whitelist the following IPs on https://cloud.google.com/sql | |
* One at a time! | |
* | |
* 64.18.0.0/20 | |
* 64.233.160.0/19 | |
* 66.102.0.0/20 | |
* 66.249.80.0/20 | |
* 72.14.192.0/18 | |
* 74.125.0.0/16 |
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 set project <your-project-id> | |
gcloud sql connect wifistr --user=root | |
use wifistr | |
select * from wifistr; |
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 base64 | |
import sqlalchemy | |
from sqlalchemy import update | |
def hello_pubsub(event, context): | |
pubsub_message = base64.b64decode(event['data']).decode('utf-8') | |
db_user = 'root' # os.environ.get("DB_USER") | |
db_pass = 'your-db-pass' # os.environ.get("DB_PASS") |
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
google-cloud-pubsub==1.0.2 | |
PyMySQL==0.9.3 | |
sqlalchemy==1.3.8 |
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
create database wifistr; | |
use wifistr; | |
create table wifistr(id int auto_increment primary key not null, wifistr varchar(32)); | |
desc wifistr; |
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 set project <your-project-id> | |
gcloud sql connect <dbname> --user=<user> |
NewerOlder