Skip to content

Instantly share code, notes, and snippets.

@viggin543
viggin543 / measure_pod_start.sh
Created April 17, 2020 18:25
a script that messures the time it takes to a single pod to become redy
#!/usr/bin/env bash
pod=$1
scheduled=`kubectl get pod $pod -o json | jq -r '.status.conditions[] | select(.type=="PodScheduled") | .lastTransitionTime' | sed 's/T/ /g' | tr -d 'Z'`
ready=`kubectl get pod $pod -o json | jq -r '.status.conditions[] | select(.type=="Ready") | .lastTransitionTime' | sed 's/T/ /g' | tr -d 'Z'`
scheduled_epoch=`date -j -u -f "%Y-%m-%d %T" "$scheduled" "+%s"` # mac os date ( linux has different
echo "${pod} sechedualed at ${scheduled_epoch}"
ready_epoch=`date -j -u -f "%Y-%m-%d %T" "$ready" "+%s"`
load_seconds=$((ready_epoch-scheduled_epoch))
echo "${pod} launch time: ${load_seconds} seconds"
SERVICE_TYPE,USAGE_DATE,CREDITS_USED_COMPUTE,CREDITS_USED_CLOUD_SERVICES,CREDITS_USED,CREDITS_ADJUSTMENT_CLOUD_SERVICES,CREDITS_BILLED
WAREHOUSE_METERING,2023-05-04,14.068333333,7.163716945,21.232050278,-1.4068333333,19.8252169447
WAREHOUSE_METERING,2022-09-16,17.436944446,7.546781387,24.983725833,-1.7436944446,23.2400313884
WAREHOUSE_METERING,2022-09-18,18.069999997,8.098243332,26.168243329,-1.8069999997,24.3612433293
WAREHOUSE_METERING,2023-04-22,14.508611108,9.363133055,23.871744163,-1.4508611108,22.4208830522
WAREHOUSE_METERING,2022-08-07,22.207777779,5.769718889,27.977496668,-2.2207777779,25.7567188901
WAREHOUSE_METERING,2022-09-04,19.141388888,5.979650277,25.121039165,-1.9141388888,23.2069002762
WAREHOUSE_METERING,2022-06-03,12.690277777,0.840071666,13.530349443,-0.8400716660,12.6902777770
WAREHOUSE_METERING,2022-08-28,19.960277777,5.817170554,25.777448331,-1.9960277777,23.7814205533
WAREHOUSE_METERING,2023-04-03,13.914444444,10.673902779,24.588347223,-1.3914444444,23.1969027786
@viggin543
viggin543 / credits.sql
Last active April 28, 2023 11:04
snowsql cloud credits per querry
select
LEFT(query_text,300),USER_NAME, COUNT(LEFT(query_text,300)) as COUNT_QUERIES, SUM(CREDITS_USED_CLOUD_SERVICES)
from SNOWFLAKE.ACCOUNT_USAGE.QUERY_HISTORY as jb
where start_time between '2023-04-27' and '2023-04-28'
GROUP BY LEFT(query_text,300), USER_NAME
order by 3 desc nulls last LIMIT 100;
@viggin543
viggin543 / metadata.sql
Created April 28, 2023 11:03
get table schema
SELECT c.COLUMN_NAME name, c.DATA_TYPE type
FROM INFORMATION_SCHEMA.COLUMNS c,
INFORMATION_SCHEMA.TABLES t
WHERE t.TABLE_NAME = c.TABLE_NAME
AND t.TABLE_SCHEMA = c.TABLE_SCHEMA
and c.TABLE_NAME = ?
@viggin543
viggin543 / rev_proxy.go
Created June 2, 2021 08:50
rev_proxy.go
package reverse_proxy
import (
"bytes"
"fmt"
"github.com/viggin/svc-api-gateway/internal/models"
"github.com/gin-gonic/gin"
"github.com/google/uuid"
"github.com/palantir/stacktrace"
"github.com/sirupsen/logrus"
name: staging tests and build
on:
push:
branches: [ staging ]
jobs:
run-ci:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
resource "google_compute_security_policy" "waf-security-policy" {
name = "waf-policy"
type = "CLOUD_ARMOR_EDGE"
rule {
action = "allow"
priority = "2147483647"
match {
versioned_expr = "SRC_IPS_V1"
config {
src_ip_ranges = ["*"]
resource "google_compute_url_map" "foo-http" {
name = "loomi-foo-http"
description = "foo http redirect"
default_url_redirect {
strip_query = false
redirect_response_code = "MOVED_PERMANENTLY_DEFAULT"
https_redirect = true
}
resource "google_compute_target_https_proxy" "foo-proxy" {
name = "foo-https-proxy"
url_map = google_compute_url_map.foo.self_link
ssl_certificates = [google_compute_managed_ssl_certificate.foo-certificate.id]
}
resource "google_compute_global_forwarding_rule" "foo-https" {
provider = google-beta
name = "foo-https-rule"
resource "google_compute_target_https_proxy" "foo-proxy" {
name = "foo-https-proxy"
url_map = google_compute_url_map.foo.self_link
ssl_certificates = [google_compute_managed_ssl_certificate.foo-certificate.id]
}
resource "google_compute_global_forwarding_rule" "foo-https" {
provider = google-beta
name = "foo-https-rule"