Skip to content

Instantly share code, notes, and snippets.

View n0531m's full-sized avatar
💭
in the ☁

Naoya Moritani n0531m

💭
in the ☁
View GitHub Profile
@n0531m
n0531m / .gitignore
Last active July 10, 2023 00:28
OpenData2BigQuery - Japan - Jukyo Jusho
data/
.DS_Store
@n0531m
n0531m / gmp_datasets.sh
Last active May 18, 2023 08:49
Google Maps Platform - Datasets API CLI
#!/bin/bash
## 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
##
## https://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,
@n0531m
n0531m / cloudsql2bq_dataflow.sh
Last active October 18, 2021 01:48
Run Cloud Dataflow template JDBC->BigQuery against Cloud SQL for MySQL with Private IP setup
#!/bin/bash
##Source : Cloud SQL Instance/Table/SQL for extraction
CLOUDSQL_INSTANCE_PROJECT=imfeelinglucky-utilities
CLOUDSQL_INSTANCE_REGION=asia-southeast1
CLOUDSQL_INSTANCE_NAME=testmysql57
CLOUDSQL_INSTANCE_USERNAME=
CLOUDSQL_INSTANCE_USERPASS=
CLOUSSQL_SQL="select * from mysql.user"
@n0531m
n0531m / pom.xml
Last active May 13, 2023 15:37
Create UberJar for CloudSQL (PostgreSQL) with Socket Factory included
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.n0531m</groupId>
<artifactId>postgresql_${postgresql.version}-with-cloudsql-socket-factory_${postgresql.socketfactory.version}</artifactId>
<packaging>pom</packaging>
<version>0.0.1-SNAPSHOT</version>
<prerequisites>
<maven>3.6.0</maven>
</prerequisites>
@n0531m
n0531m / pom.xml
Last active May 14, 2023 07:58
Create UberJar for CloudSQL (MySQL) with Socket Factory included
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.gmail.n0531m</groupId>
<artifactId>mysql_${mysql.version}-with-cloudsql-socket-factory_${cloudsql.socketfactory.version}</artifactId>
<packaging>pom</packaging>
<version>0.0.1</version>
<prerequisites>
<maven>3.6.0</maven>
</prerequisites>
@n0531m
n0531m / README.md
Last active February 22, 2022 04:05
Extract metadata (Reports/Data Srouces) from Data Studio

Extract metadata from Data Studio

this is some example code I used to extract metadata (REPORT/DATA_SOURCE) from Data Studio.

Warning : Information provided via Data Studio API very limited. So if you are looking for ways to understand more details such as what are the constructs of a REPORT or what backend a DATA_SOURCE is connecting to, unfortunately these will not help. That said, it can still be better than nothing so that you know what assets are existing within the organization.

Extracted information can be potentially cataloged in some other services such as Data Catalog. However, that is beyond what this sample covers.

products in use

@n0531m
n0531m / install_basics.sh
Last active December 26, 2023 01:51
setting up my chromebook
##!/bin/bash
## setting up the least to a clean linux env on a chromebook
## mostly a copy&paste from instructions found on the web, which is why the approach is not consistent...
## i might clean it up in the future but as long as it works it does the job.
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install apt-transport-https ca-certificates gnupg software-properties-common apt-utils
@n0531m
n0531m / indonesia_admin_boundaries_to_bigquery.md
Last active February 22, 2021 01:57
Indonesia Admin boundaries to BigQuery #bigquery #opendata #indonesia
@n0531m
n0531m / bearing.sql
Last active May 24, 2020 14:51
UDF to calculate bearing in BigQuery
#
# https://en.wikipedia.org/wiki/Radian
# https://towardsdatascience.com/calculating-the-bearing-between-two-geospatial-coordinates-66203f57e4b4
CREATE TEMP FUNCTION
PI (degree float64) AS (ACOS(-1));
CREATE TEMP FUNCTION
RADIANS (degree FLOAT64) AS (degree * ACOS(-1) / 180);
CREATE TEMP FUNCTION
@n0531m
n0531m / covic19_publicdataset_locationname_fluctuation_check.sql
Last active April 4, 2020 08:02
covic19_publicdataset_locationname_fluctuation
#DECLARE # PRECISION INT64 DEFAULT 6;
DECLARE PRECISION_GEOHASH INT64 DEFAULT 2;
WITH # first table : only aggregating the rows with exact match on country_region, province_state, longitude, latitude
# also rounding lat/lng to a set precision. (defined in declard param)
# also adding a geohash value based point point
t1 AS
( SELECT CASE
WHEN country_region IN ("South Korea",
"Korea, South",