This file contains 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
# 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 \ |
This file contains 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
/* 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: |
This file contains 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
# %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, ...) { |
This file contains 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
#!/bin/bash | |
# Uninstall things you installed with a pkg on Mac | |
# Tested on El Capitan | |
# Please run this at your own risk | |
# Read: http://superuser.com/questions/36567/how-do-i-uninstall-any-apple-pkg-package-file | |
if [ "$EUID" -ne 0 ] | |
then | |
echo "Please run as root" |
This file contains 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
#stepwise VIF function | |
stepwiseVIF <- function(in_frame,thresh=10,trace=T){ | |
require(fmsb) | |
if(class(in_frame) != "data.frame") in_frame <- data.frame(in_frame) | |
#get initial vif value for all comparisons of variables | |
vif_init <- NULL | |
for(val in names(in_frame)){ | |
form_in <- formula(paste(val," ~ .")) |
This file contains 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
# Adopted from http://www.cookbook-r.com/Graphs/Multiple_graphs_on_one_page_(ggplot2) | |
# And uploaded as gist for my personal use. | |
# | |
# Multiple plot function | |
# | |
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects) | |
# - cols: Number of columns in layout | |
# - layout: A matrix specifying the layout. If present, 'cols' is ignored. | |
# | |
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), |
This file contains 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
# Caches the query result in rds file under `getwd()`/psql_cache. | |
# It assumes pg_host, pg_port, pg_dbname, pg_user, pg_password variables in the env. | |
# Remove the cache files if the update value is needed. | |
# Expire: | |
# positive integer n: Expire if the existing cache is older than n minutes | |
# 0: Expire now | |
# -1: Always use the existing cache if it exists | |
cachedPsqlQuery <- function(queryName, query, expire=-1, cachePath="./psql_cache") { | |
require(RPostgreSQL) | |
This file contains 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
; the macro source | |
; To understand pub sub in clojure and ClojureScript, read this: | |
; https://yobriefca.se/blog/2014/06/04/publish-and-subscribe-with-core-dot-asyncs-pub-and-sub/ | |
; define this in my-app/src/my-app/macros.clj | |
(ns my-app.macros) | |
(defmacro defsubfn | |
"Macro for subscriber function in pub-sub pattern" | |
[fnname channel body] | |
`(do |
This file contains 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
# Modify stdout by rChart so I can customize tooltip and etc | |
require(rCharts) | |
renderChart = function (ct, chartId, include_assets = F, ...) | |
{ | |
add_ext_widgets(ct$lib) | |
assetHTML <- ifelse(include_assets, paste(paste(add_lib_assets(ct$lib, | |
...), collapse = "\n"), "\n", add_style_(ct$params$width, | |
ct$params$height), collapse = "\n"), "") | |
chartDiv = render_template(ct$templates$chartDiv, list(chartId = chartId, | |
lib = ct$LIB$name, container = ct$container)) |
NewerOlder