Skip to content

Instantly share code, notes, and snippets.

💭
in the ☁

Naoya Moritani n0531m

💭
in the ☁
  • Singapore
Block or report user

Report or block n0531m

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@n0531m
n0531m / pom.xml
Created Aug 19, 2019
postgres-with-cloud-sql-socket-factory
View pom.xml
<?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">
<!--
# full credit to one of the comments here https://stackoverflow.com/questions/55880595/cant-connect-cloud-data-fusion-with-google-cloud-sql-for-postgresql
# just updated the dependency and mvn plugin versions
$ mvn clean package
-->
<modelVersion>4.0.0</modelVersion>
<groupId>com.altostrat.moritani</groupId>
@n0531m
n0531m / list_gcp_zones_skylake.sh
Created May 29, 2019
list GCP zones with Skylake
View list_gcp_zones_skylake.sh
#!/bin/bash
gcloud --format json compute zones list | jq -r '.[] | select((.availableCpuPlatforms[]) | contains("Intel Skylake")) | .name'
@n0531m
n0531m / check_project_quota.sh
Last active Apr 4, 2019
GCP : Check project quota
View check_project_quota.sh
#!/bin/bash
## lists project quota in use
## "jq" is required
## usage: ./checkquota.sh <PROJECTID>
PROJECT=$1
NOW=`date +%Y-%m-%d`
gcloud compute regions list --format json --project $PROJECT \
@n0531m
n0531m / bq_udf_voronoi.sql
Last active Aug 24, 2018
A query in BigQuery that leverages a Javascript library to compute a voronoi diagram.
View bq_udf_voronoi.sql
#standardSQL
CREATE TEMP FUNCTION
testVolonoi (data ARRAY<STRUCT<x float64, y float64, id string, name string>>, margin_ratio float64)
RETURNS ARRAY<STRUCT<id string, name string, wkt String>>
LANGUAGE js AS """
let xl,xr=data[0].x;
let yt,yb=data[0].y;
for(i=1;i<data.length;i++){
if(data[i].x < xl) xl=data[i].x ;
View find_my_ip.sh
#!/bin/bash
wget -qO - http://ipecho.net/plain; echo
@n0531m
n0531m / drivedocs2pdf.js
Created Feb 20, 2018
Convert Google Docs/Slides/Sheets to PDF
View drivedocs2pdf.js
function clear(){
var pdf_folderid="XXXXXXX";
_clearPDFs(pdf_folderid);
}
function convert(){
var src_folderid="YYYYYYY";
var pdf_folderid="XXXXXXX";
_doc2pdf(src_folderid,pdf_folderid);
}
View gist:9025a52c8bd4d87ebeeb1669d2822fa3
#https://superuser.com/questions/165652/how-can-i-clean-up-my-macports-installation
sudo /opt/local/bin/port -f clean --all all
sudo /opt/local/bin/port -f uninstall inactive
sudo rm -rf /opt/local/var/macports/distfiles/*
sudo rm -rf /opt/local/var/macports/packages/*
sudo /opt/local/bin/port uninstall inactive
@n0531m
n0531m / runBeamPipeline.sh
Created Nov 15, 2017
running a beam pipeline from cli
View runBeamPipeline.sh
#!/bin/bash
PROJECTID=moritani-bigdata
DATASET=opendatasg
RUNNER=DirectRunner
#RUNNER=DataflowRunner
mvn compile exec:java \
-Dexec.mainClass=com.gmail.n0531m.datagovsg.pipelines.TaxiAvailabilityPipeline \
-Dexec.cleanupDaemonThreads=false \
@n0531m
n0531m / bigquery_udf_latlng2coordinates.sql
Last active Oct 30, 2017
calculate coordinates from latlng
View bigquery_udf_latlng2coordinates.sql
# this is a udf sample to calculate coordinates from latlng
# https://developers.google.com/maps/documentation/javascript/examples/map-coordinates
CREATE TEMPORARY FUNCTION
project (latitude FLOAT64, longitude FLOAT64, zoom FLOAT64)
RETURNS STRUCT < worldCoordinate_x float64,
worldCoordinate_y float64,
pixelCoordinate_x float64,
pixelCoordinate_y float64,
tileCoordinate_x float64,
tileCoordinate_y float64 >
@n0531m
n0531m / datalab_update.sh
Created May 21, 2017
update local datalab container image
View datalab_update.sh
#!/bin/bash
docker pull gcr.io/cloud-datalab/datalab:local
You can’t perform that action at this time.