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 / listDlvmImages.sh
Created March 11, 2020 07:08
GCP : list deep learning VMs
#!/bin/bash
gcloud --project deeplearning-platform-release \
compute images list --no-standard-images
function getBqTempTableByJobid {
local JOBID=$1
bq show --format json -j ${JOBID} \
| jq -r '.configuration.query.destinationTable | .projectId +":"+.datasetId+"."+.tableId'
}
@n0531m
n0531m / date_range.sql
Last active March 23, 2024 01:39
BigQuery : Generate range of dates
SELECT day
FROM UNNEST(
GENERATE_DATE_ARRAY(DATE('2020-01-01'), DATE('2020-01-31'), INTERVAL 1 DAY)
) as day
@n0531m
n0531m / gist:3a163ae52c343731be1df8703177aa0f
Created December 2, 2019 20:51
show the actual rotation and not auto-rotate the image when in preview
defaults write com.apple.Preview PVImagePrintingAutoRotate 0
@n0531m
n0531m / pom.xml
Created August 19, 2019 11:17
postgres-with-cloud-sql-socket-factory
<?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 05:23
list GCP zones with Skylake
#!/bin/bash
gcloud --format json compute zones list | jq -r '.[] | select((.availableCpuPlatforms[]) | contains("Intel Skylake")) | .name'
@n0531m
n0531m / check_project_quota.sh
Last active April 4, 2019 06:13
GCP : Check project quota
#!/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 August 24, 2018 08:25
A query in BigQuery that leverages a Javascript library to compute a voronoi diagram.
#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 ;
#!/bin/bash
wget -qO - http://ipecho.net/plain; echo
@n0531m
n0531m / drivedocs2pdf.js
Created February 20, 2018 14:49
Convert Google Docs/Slides/Sheets to PDF
function clear(){
var pdf_folderid="XXXXXXX";
_clearPDFs(pdf_folderid);
}
function convert(){
var src_folderid="YYYYYYY";
var pdf_folderid="XXXXXXX";
_doc2pdf(src_folderid,pdf_folderid);
}