- Configure org policies
- Restrict allowed IAM domains
- Disable key download
- Disable default network
- Disable external IP
- Require shielded VM
- Prepare for VPC service controls (data protection)
This file contains hidden or 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
#standardSQL | |
SELECT | |
event_id, issue_id, blame_frame.file, blame_frame.line | |
FROM | |
`projectId.firebase_crashlytics.package_name_ANDROID` | |
WHERE | |
FORMAT_TIMESTAMP("%Y%m%d", TIMESTAMP_TRUNC(event_timestamp, DAY)) = '20190509' |
This file contains hidden or 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
SELECT COUNT(distinct p.user_id) | |
FROM `friendly--pix.projectId.firebase_predictions.YOUR_PACKAGE_NAME_ANDROID` p CROSS JOIN UNNEST (predictions) | |
WHERE | |
prediction_name = "churn" | |
AND score > 0.7 | |
AND TIMESTAMP_TRUNC(p.prediction_time, DAY) = TIMESTAMP('2018-10-04') |
This file contains hidden or 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
SELECT | |
AVG(trace_info.duration_us / 1000000) AS seconds_on_screen, | |
AVG(trace_info.screen_info.slow_frame_ratio) AS slow_frame_ratio, | |
AVG(trace_info.screen_info.frozen_frame_ratio) AS frozen_frame_ratio, | |
event_name as screen, | |
country | |
FROM `friendly--pix.projectId.firebase_performance.YOUR_PACKAGE_NAME_ANDROID` | |
WHERE _PARTITIONTIME > TIMESTAMP("2019-05-09") | |
AND event_type = "SCREEN_TRACE" | |
AND country = "FR" |
This file contains hidden or 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 pandas as pd | |
from pandas.io.json import json_normalize | |
from pymongo import MongoClient | |
import matplotlib.pyplot as plt | |
import re | |
import time | |
pd.set_option('display.expand_frame_repr', False) | |
def _connect_mongo(host, port, db): |
This file contains hidden or 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 pandas as pd | |
from scipy.cluster.hierarchy import fclusterdata | |
from pymongo import MongoClient | |
import numpy as np | |
from datetime import * | |
import json | |
def saveToRelational(jsonPacket): | |
""" | |
save the received json packet to a relational database |
This file contains hidden or 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 pandas as pd | |
import numpy as np | |
import re, os, time, csv, random, pymongo, math, html, string, html2text | |
from pymongo import MongoClient | |
import xml.etree.ElementTree as ET | |
import pymongo | |
import sklearn | |
This file contains hidden or 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 json | |
import pandas as pd | |
from pymongo import MongoClient | |
def mongo_to_pandas(client, database, collection): | |
""" Reads mongo collection to pandas data frame.""" | |
cur = client[database][collection].find() | |
df = pd.DataFrame(list(cur)) | |
df["_id"] = df["_id"].apply(lambda x: str(x)) #convert ids to strings |
This file contains hidden or 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 reaching_max_messages(current_hour_bitrange): | |
""" | |
from https://stackoverflow.com/a/29281409 | |
""" | |
# https://stackoverflow.com/a/29281409 | |
# https://docs.mongodb.com/manual/reference/operator/query/bitsAllSet/ | |
pipeline = [ | |
{ |
This file contains hidden or 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
# @Author: xiewenqian <int> | |
# @Date: 2016-11-28T20:35:09+08:00 | |
# @Email: [email protected] | |
# @Last modified by: int | |
# @Last modified time: 2016-12-01T19:32:48+08:00 | |
import pandas as pd | |
from pymongo import MongoClient |