Skip to content

Instantly share code, notes, and snippets.

View amacal's full-sized avatar

Adrian Macal amacal

View GitHub Profile
create transient table ecds_db.playground.orders
(
id bigint,
id_prev bigint,
)
with recursive hierarchy(id, id_prev, length) as
(
-- only roots
select id, id_prev, 1 as length
from ecds_db.playground.orders
where id_prev is null
union all
-- only joinable children
select o.id, o.id_prev, p.length + 1
from ecds_db.playground.orders o
with level1 as
(
select id, id_prev, 1 as length
from ecds_db.playground.orders
),
-- up to 4 links
level2 as
(
select j1.id,
case when j4.id is not null then j4.id_prev when j3.id is not null then j3.id_prev when j2.id is not null then j2.id_prev else j1.id_prev end as id_prev,
const axios = require('axios');
const querystring = require('querystring');
module.exports = async function({ Username, Password }) {
const result = await axios({
method: 'post',
url: 'https://login.microsoftonline.com/common/oauth2/token',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
data: querystring.stringify({
client_id: 'ea0616ba-638b-4df5-95b9-636659ae5121',
GET /v1.0/myorg/dashboards HTTP/1.1
Host: api.powerbi.com
Accept: application/json
Authorization: Bearer <token>
if [ ! -f "$1" ]; then
exit 1
fi
SHA=`cat $1 | openssl dgst -binary -sha256 | openssl base64`
BIN=`cat $1 | openssl dgst -sha256 | awk '{print $2}'`
echo "{ \"filebase64sha256\": \"$SHA\", \"binary\": \"$BIN\", \"status\": \"success\" }"
# variables
variable "layer_file" {}
variable "layer_name" {}
variable "layer_runtime" {}
variable "deployment_bucket" {}
variable "deployment_file" {}
# compute hash
data "external" "hash" {
program = ["/bin/sh", "${path.module}/filebase64sha256.sh", var.layer_file]
resource "aws_sns_topic" "orders" {
name = "orders-topic"
}
resource "aws_sqs_queue" "orders_to_process" {
name = "orders-to-process-queue"
receive_wait_time_seconds = 20
message_retention_seconds = 18400
}
resource "aws_sqs_queue_policy" "orders_to_process_subscription" {
queue_url = aws_sqs_queue.orders_to_process.id
policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "sns.amazonaws.com"
resource "aws_sns_topic_subscription" "orders_to_process_subscription" {
protocol = "sqs"
raw_message_delivery = true
topic_arn = aws_sns_topic.orders.arn
endpoint = aws_sqs_queue.orders_to_process.arn
}
resource "aws_sns_topic_subscription" "orders_to_notify_subscription" {
protocol = "sqs"
raw_message_delivery = true