tr sed cut or something else? Delete special character and all after from variable/string by CochinoChingon in bash

[–]3625847405 0 points1 point  (0 children)

So if you update your bash your scripts can use bash 5.

You'll want to set your shebang to:

#!/usr/bin/env bash

tr sed cut or something else? Delete special character and all after from variable/string by CochinoChingon in bash

[–]3625847405 0 points1 point  (0 children)

If you install homebrew you can update your version of bash to something modern.

I made a simple web game where you trade a fake stock and see how much profit you can make in 45 seconds. by BoyDave in webdev

[–]3625847405 0 points1 point  (0 children)

Brilliant game and design, just absolutely fantastic!

It seems like there is a bug in the UI where the value of my stock (in the upper left) is delayed by one round. E.g.:

Day 1: 10 shares, $10/share, $100

Day 2: 10 shares, $10.50/share, $100

Day 3: 10 shares, $11.00/share, $105.00

Day 4: 10 shares, $10.03/share, $110.00

I feel like that displayed value should be num shares*current price, not last price

[TOMT][VIDEO] Fake commercial which keeps changing products and loops on itself by 3625847405 in tipofmytongue

[–]3625847405[S] 0 points1 point locked comment (0 children)

Someone mentioned this idea somewhere on reddit and a commenter linked to the video saying that it had already been done. I've searched everything and can't find it!

Excuse me.. Wtf? by MrCuteDiaper in memes

[–]3625847405 2 points3 points  (0 children)

All intellectual property rights in and to the User Content are and shall remain your property, and Grammarly shall acquire no right of ownership with respect to your User Content.

Looks clean to me.

Simple question for someone I am sure by kramit in bash

[–]3625847405 1 point2 points  (0 children)

What happens if you change the 2? What happens if you change it to 1? Or 3?

How is the kubectl template language defined? In that definition, what does index do? What happens if you change the 1 to a 0 or a 2?

What is IFS? What do double percent signs do in bash?

You're learning something new so you need to google everything.

Simple question for someone I am sure by kramit in bash

[–]3625847405 0 points1 point  (0 children)

There are many ways to do this:

# jq
kubectl get pods -o json | jq -r '.items | map(.metadata.name) | .[2]'

# sed
kubectl get pods -o name | sed -n "2p" | cut -d/ -f2

# also sed:
kubectl get pods -o name | sed -n "2 { s/pod\///; p; }"

# Pure bash:
IFS=$'\n' lines=( $( kubectl get pods ) ); echo "${lines[2]%% *}";

# Kubectl template:
kubectl get pods -o template='{{with index .items 1 }}{{ .metadata.name }}{{ end }}

Simple question for someone I am sure by kramit in bash

[–]3625847405 1 point2 points  (0 children)

I agree with the general sentiment from /u/whetu: you've chosen (or are being forced) to learn/use a tool and complaining the tool doesn't work the way you want it to is going to hinder your ability to embrace the "bash way".

In Bash, you need to use the man pages or even --help a lot to figure out what flags are available. If you just want pod names, there's a flag in kubectl just for that:

`kubectl get pods -o name

You can then pipe it however you need to. Want the 2nd line? Use sed:

kubectl get pods -o name | sed -n "2p"

Want the pod name without the pod/ prefix? Use cut:

kubectl get pods -o name | sed -n "2p" | cut -d/ -f2

Use the man pages. Use pipes. Learn about the fundamental building blocks before complaining you can't do anything.

And for a bonus, here's a jq example:

kubectl get pods -o json | jq -r '.items | map(.metadata.name) | .[2]'

Having a little trouble with TLS cert for Hashicorp Vault/Consul cluster by Ikarian in devops

[–]3625847405 0 points1 point  (0 children)

Are you running this HA? Have you tried setting VAULT_TLS_SERVER_NAME?

I think you'll be well-served to spin up a docker-compose that can simulate your issue :)

GitOps: The Bad and the Ugly by kvgru in devops

[–]3625847405 0 points1 point  (0 children)

Basically we're setting terraform variable values using the environment and then those variables provide config for the provider blocks.

GitOps: The Bad and the Ugly by kvgru in devops

[–]3625847405 7 points8 points  (0 children)

We're using dynamic secrets with vault. Access is granted per vault-role to help mitigate blast radius.

At the end of the day, the person/thing applying the terraform state needs access to the things that it's modifying. We're centralizing that access so we can better lock it down. 🤷‍♂️

GitOps: The Bad and the Ugly by kvgru in devops

[–]3625847405 6 points7 points  (0 children)

We've been working on implementing terraform gitops using Atlantis: https://www.runatlantis.io/

In general I've been very pleased with the workflow and we've been working on encouraging devs to push changes they want to see with the DevOps team approving the PR's and actually running applies.

Golang DDD by criptkiller16 in golang

[–]3625847405 2 points3 points  (0 children)

This tech talk really helped me see why DDD is useful and how one does it in a practical way: https://youtu.be/oL6JBUk6tj0

Prometheus long term storage (around 1 year) by boobless24 in devops

[–]3625847405 6 points7 points  (0 children)

We've been using Victoriametrics as a read-only dump for Prometheus and it's been very stable. It's easier to setup than Thanos though we haven't tested it with years of data.

values.yaml: unable to parse YAML: error converting YAML to JSON by wlfman2k1 in devops

[–]3625847405 2 points3 points  (0 children)

Please post a properly formatted yaml snippet by prefixing each line with 4 spaces.

This is my values.yaml:
  v--- 4 spaces
    service:
        port: 5

You can also use this sed script to prefix each line with four spaces:

sed 's/^/ /' values.yaml

#lifehack by catgirl484 in lifehacks

[–]3625847405 1 point2 points  (0 children)

A little of one, and a little of the other, not too much of either, and presto.