This file contains hidden or 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 | |
region=us-east-1 | |
query='SELECT NOW()' | |
output_location="s3://aws-athena-query-results-1234567890-$region/" | |
query_execution_id=$(aws athena start-query-execution \ | |
--region "$region" \ | |
--query-string "$query" \ | |
--result-configuration "OutputLocation=$output_location" \ |
This file contains hidden or 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
// this is an attempt to create a synchronous InputStream from a call to | |
// S3AsyncClient#getObject using a blocking queue. | |
// | |
// the purpose is to be able to make many S3 operations asynchronously, but | |
// at the same time be able to pass off some results to threads and into | |
// code that expects InputStream or Reader, like a Commons CSV. | |
public class InputStreamResponseTransformer extends InputStream implements AsyncResponseTransformer<GetObjectResponse, InputStream>, Subscriber<ByteBuffer> { | |
private static final ByteBuffer END_MARKER = ByteBuffer.allocate(0); |
This file contains hidden or 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 ruby | |
# This code parses the .csv.metadata files written by Athena and produces a | |
# structure similar to what you get from the GetQueryResults API call. | |
# | |
# I have reverse engineered the format and I'm not sure about all the details, | |
# but it seems to correspond to the GetQueryResults API call well. Some things, | |
# like nullability, the difference between name and label, and the schema_name | |
# and table_name fields, I haven't been able to figure out because they seem | |
# not to be used, or never takes any other values. |
This file contains hidden or 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
-- Connection limits by role | |
SELECT rolname, rolconnlimit | |
FROM pg_roles | |
WHERE rolconnlimit <> -1; | |
-- Change connection limit for a role | |
ALTER USER $role WITH CONNECTION LIMIT 64; | |
-- Current activity | |
SELECT * |
This file contains hidden or 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
require 'aws-sdk-glue' | |
require 'aws-sdk-s3' | |
def split_s3_uri(s3_uri) | |
s3_uri.match(%r{\As3://(.+?)/(.+)\z}).to_a.drop(1) | |
end | |
database, table_name = ARGV.take(2) | |
glue = Aws::Glue::Client.new |
This file contains hidden or 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
-- this creates a schema called "name_of_schema_in_redshift" in Redshift, | |
-- that works as an alias for the Athena/Glue database "name_of_database_in_glue". | |
CREATE EXTERNAL SCHEMA name_of_schema_in_redshift | |
FROM DATA CATALOG | |
DATABASE 'name_of_database_in_glue' | |
REGION 'us-east-1' | |
IAM_ROLE 'arn:aws:iam::456064453472:role/xyz'; |
This file contains hidden or 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
require 'aws-sdk-ec2' | |
ec2 = Aws::EC2::Client.new | |
response = ec2.describe_security_groups | |
puts('digraph securitygroups {') | |
loop do | |
response.security_groups.each do |security_group| |
This file contains hidden or 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
-- Discovers all partitions of a table if they use Hive's partitioning format (e.g. partition0=abc/partition1=def) | |
MSCK REPAIR TABLE tablename; |
This file contains hidden or 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 | |
function log() { | |
logger -st "cbck[$$]" "$@" | |
} | |
function check_failed() { | |
log -p user.err "Check failed: $1" | |
exit 1 | |
} |
This file contains hidden or 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
# Running this script with `ruby -w` will print these warnings: | |
# .../lib/ruby/1.9/webrick/https.rb:26 warning: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated | |
# .../lib/ruby/1.9/webrick/https.rb:27 warning: javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated | |
require 'webrick' | |
require 'webrick/https' | |
require 'net/https' | |
require 'logger' | |
def create_root_ca(cn) |
NewerOlder