Skip to content

Instantly share code, notes, and snippets.

View daigotanaka's full-sized avatar
😎
https://handoff.cloud

Daigo Tanaka daigotanaka

😎
https://handoff.cloud
View GitHub Profile
@daigotanaka
daigotanaka / sprintf_.r
Last active January 11, 2017 05:26
sprintf that takes key-value inputs in the format
# %format% by G. Grothendieck from http://stackoverflow.com/a/17476306/3423480
library(gsubfn)
`%format%` <- function(fmt, list) {
pat <- "%\\(([^)]*)\\)"
fmt2 <- gsub(pat, "%", fmt)
list2 <- list[strapplyc(fmt, pat)[[1]]]
do.call("sprintf", c(fmt2, list2))
}
sprintf_ <- function(format, ...) {
@daigotanaka
daigotanaka / histogram.sql
Last active July 5, 2019 02:04
SQL histogram template
/* Histogram template
Edit Config and Input sections at the top of this query.
Config:
- bin_size: Width of the bin
- min_bin
- max_bin
Input:
@daigotanaka
daigotanaka / cfn.yml
Created June 23, 2020 22:57
Fixing AWS Fargate FailedInvocation error
# My Fargate tasks suddenly stopped working around 6/20/2020 after many months of stable executions.
# I tried using the following role and it worked.
# Reference: https://stackoverflow.com/a/51536083
#
# You can look for the ARN for the generated role by running:
# ROLE=aws iam list-roles --query 'Roles[?contains(RoleName, `CloudWatchEventECSRole`)].Arn | [0]'
#
# You can use the role when scheduling the task on Fargate
# aws events put-targets --profile $AWS_PROFILE \
# --rule $SCHEDULE_RULE_NAME \