Skip to content

Instantly share code, notes, and snippets.

apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
annotations:
iam.gke.io/gcp-service-account: argocd-backup@<GCP-PROJECT_KEY>.iam.gserviceaccount.com
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
@viggin543
viggin543 / cart.json
Created April 19, 2021 09:23
cart_with_absolute_discount_code_and_a_relative_discount_code.json
{
"version": 17,
"totalPrice": {
"type": "centPrecision",
"fractionDigits": 2,
"currencyCode": "USD",
"centAmount": 4930000
},
"taxedPrice": {
"totalNet": {
func calcTotalDiscount(currentCart *commercetools.Cart, response *cart_service.CartPriceSummeryResponse) {
if len(currentCart.DiscountCodes) != 0 {
for _, lineItem := range currentCart.LineItems {
for _, discountedPrice := range lineItem.DiscountedPricePerQuantity {
response.TotalDiscount += centAmount(discountedPrice.DiscountedPrice.Value) * int32(discountedPrice.Quantity)
}
}
for _,code := range currentCart.DiscountCodes {
if code.State == commercetools.DiscountCodeStateMatchesCart {
for _, cartDiscount := range code.DiscountCode.Obj.CartDiscounts {
{
"version": 18,
"totalPrice": {
"type": "centPrecision",
"fractionDigits": 2,
"currencyCode": "USD",
"centAmount": 77600
},
"taxRoundingMode": "HalfEven",
"taxMode": "External",
@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"
ssh -o StrictHostKeyChecking=no -t -t \
-i ./github_id_rsa "${SHH_USER}@${BASTION_IP}" \
-L "3306:${MYSQL_IP}:3306" &
resource "google_service_account" "bastion" {
project = var.project
account_id = "bastion"
display_name = "ssh bastion"
}
locals {
bastion = "bastion"
}
echo -n "${PRIVATE_KEY}" | base64 --decode > github_id_rsa
sudo chmod 600 github_id_rsa
- name: clean ssh key
if: always()
run: rm -rf github_id_rsa
func (this *usersService) IsMagicLinkVerified(ctx context.Context, in *users.IsMagicLinkVerifiedRequest) (*users.IsMagicLinkVerifiedResponse, error) {
c, _ := context.WithDeadline(ctx, time.Now().Add(25*time.Second))
ticker := ImmediateTicker(c, time.Second)
for {
select {
case <-c.Done():
return &users.IsMagicLinkVerifiedResponse{Status: users.MagicLinkStatus_unknown}, nil
case <-ticker:
status, token := this.tokensRepo.IsMagicLinkVerified(in.SessionId)
if status != users.MagicLinkStatus_unknown {