- R Markdown
Use a productive notebook interface to weave together narrative text and code to produce elegantly formatted output. Use multiple languages including R, Python, and SQL.
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
-- Table information like sortkeys, unsorted percentage | |
-- see http://docs.aws.amazon.com/redshift/latest/dg/r_SVV_TABLE_INFO.html | |
SELECT * FROM svv_table_info; | |
-- Table sizes in GB | |
SELECT t.name, COUNT(tbl) / 1000.0 AS gb | |
FROM ( | |
SELECT DISTINCT datname, id, name | |
FROM stv_tbl_perm | |
JOIN pg_database ON pg_database.oid = db_id |
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
#!/usr/bin/env bash | |
set -euo pipefail | |
for BRANCH in $(git branch | grep -E -v "^(\* | (develop|master|main)$)"); do | |
if [[ -z $(git --no-pager log develop..$BRANCH --author=$(git config user.email)) ]]; then | |
git branch -D $BRANCH | |
fi | |
done |
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
import sys | |
def getarg(argname, args=sys.argv[1:]): | |
long_arg = '--' + argname | |
short_arg = '-' + argname[:1] | |
for idx, arg in enumerate(args): | |
if arg.startswith(long_arg): | |
if arg == long_arg: | |
# check for parameter |
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
with recursive r(a, b) as ( | |
select 0::int, 1::int | |
union all | |
select b, a + b from r where b < 1000 | |
) | |
select a from r; | |
a | |
----- | |
0 |
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
# Add the following 'help' target to your Makefile | |
# And add help text after each target name starting with '\#\#' | |
help: ## Show this help. | |
@fgrep -h "##" $(MAKEFILE_LIST) | fgrep -v fgrep | sed -e 's/\\$$//' | sed -e 's/##//' | |
# Everything below is an example | |
target00: ## This message will show up when typing 'make help' | |
@echo does nothing |
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
<html> | |
<body> | |
<!-- ----------------------------------------------- --> | |
<!-- inline script block with commented code inside: --> | |
<!-- ----------------------------------------------- --> | |
<script id="myjscode"> | |
/* | |
(function(h,v){function q(b){if(""===m)return b; |
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
-- show running queries (pre 9.2) | |
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query | |
FROM pg_stat_activity | |
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%' | |
ORDER BY query_start desc; | |
-- show running queries (9.2) | |
SELECT pid, age(clock_timestamp(), query_start), usename, query | |
FROM pg_stat_activity | |
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%' |