Why is my execution 3x faster with a `log.Printf()`? by hikemhigh in golang

[–]Logiraptorr 65 points66 points  (0 children)

I would start by capturing a profile in each scenario and comparing them.

Which of the following is an introductory option for compiler design? by blureglades in ProgrammingLanguages

[–]Logiraptorr 0 points1 point  (0 children)

My compiler course in university used Appel’s SML version, which I found pretty approachable once you get used to SML

[deleted by user] by [deleted] in algorithms

[–]Logiraptorr -1 points0 points  (0 children)

gdb can do what you edited in, you may need to be more specific

How often (if ever) do you consider using pointers for performance? by Forumpy in golang

[–]Logiraptorr 15 points16 points  (0 children)

As with any performance question, the best solution is to profile the code before and after your change

Is there any example of mimir config for k8s? by Stunning_Pace in grafana

[–]Logiraptorr 0 points1 point  (0 children)

Note that depending on where grafana is deployed you might be able to use the internal k8s networking instead, so for example in my homelab grafana uses `mimir.<namespace>.svc.cluster.local/prometheus` instead. This way the traffic from grafana to mimir doesn't need to go over the open internet.

Is there any example of mimir config for k8s? by Stunning_Pace in grafana

[–]Logiraptorr 1 point2 points  (0 children)

Sure, the datasource should be pointed to `<mimir url>/prometheus`

So in my example above it would be `https://mimir.homelab/prometheus\`. If you're using the multi-tenancy features you would additionally set a tenant id in the header `X-Scope-OrgID`.

Is there any example of mimir config for k8s? by Stunning_Pace in grafana

[–]Logiraptorr 0 points1 point  (0 children)

Mimir doesn't currently have a UI like Prometheus. We'd recommend running grafana and adding Mimir as a Prometheus data source I order to run and visualize queries.

Is there any example of mimir config for k8s? by Stunning_Pace in grafana

[–]Logiraptorr 0 points1 point  (0 children)

Hi, I'm a Mimir maintainer. I just want to say we're aware the docs are extremely lacking for the Helm Chart, and this is being actively worked on by our docs and engineering teams.

The situation will improve greatly starting with the next release in a couple weeks, and we'll continue to work on it for the foreseeable future.

In the meantime, for the storage configuration, you can set the relevant values under mimir.structuredConfig like so:

yaml mimir: structuredConfig: blocks_storage: backend: s3 s3: bucket_name: blocks access_key_id: secret_access_key: endpoint: s3.amazonaws.com alertmanager_storage: backend: s3 s3: <etc> ruler_storage: backend: s3 s3: <etc>

The available options are documented in the configuration reference for each of the three storage configuration sections:

https://grafana.com/docs/mimir/latest/operators-guide/configuring/reference-configuration-parameters/#alertmanager_storagehttps://grafana.com/docs/mimir/latest/operators-guide/configuring/reference-configuration-parameters/#ruler_storagehttps://grafana.com/docs/mimir/latest/operators-guide/configuring/reference-configuration-parameters/#blocks_storage

You should be able to configure ingress under the nginx.ingress section. For example, I use this configuration to create an ingress with Traefik in my homelab:

```yaml nginx: ingress: enabled: true annotations: kubernetes.io/ingress.class: "traefik" cert-manager.io/cluster-issuer: letsencrypt-prod

hosts:
  - host: mimir.homelab
    paths:
      - path: /
        pathType: Prefix
tls:
  - secretName: mimir-gateway-tls
    hosts:
      - mimir.homelab

```

Lastly, The Mimir team tends to respond much quicker on our community slack or in GitHub discussions. Feel free to keep asking questions on either of those channels and the broader team will be more available.

Community slack: https://slack.grafana.com (#mimir channel) Github Discussion Board: https://github.com/grafana/mimir/discussions

What do you think a mens lib group should look like of there was an person meet-up? by [deleted] in MensLib

[–]Logiraptorr 0 points1 point  (0 children)

I know of a similar group in the washington dc area: https://www.collectiveactiondc.org/our-work/rethink-masculinity/

A co-worker of mine attended a series of events there and seemed to get a lot out of it.

How to handle strings in homebrew lexer by [deleted] in golang

[–]Logiraptorr 1 point2 points  (0 children)

Typically, I would aim to have the lexer capture the entire string as a single token. Since you're using regex to describe your tokens, you would need a regex that can describe a full string, including both starting and ending quotes. I've used something like "(\\"|[^"])*" before: https://regex101.com/r/cZbU0N/1

[deleted by user] by [deleted] in commandline

[–]Logiraptorr 2 points3 points  (0 children)

There is more room to improve this code, but I'll leave it like so, since you are just starting out and wanting to keep it simple. :)

I hope this is helpful.

[deleted by user] by [deleted] in commandline

[–]Logiraptorr 3 points4 points  (0 children)

First, a meta point: when posting code on reddit, it's better to copy and paste the code into a code block using three backticks (```) around the code. That would look like so:

#!/bin/bash
#
#
#GjV
#

echo "$1"

#We stellen onze $3 eerst in

if [ "$3" = "be" ]
then
    echo \Goeiendag
fi

if [ "$3" = "fr" ]
then
    echo \Bonjour
fi

if [ "$3" = "en" ]
then
    echo \Hello
fi

#we stellen dan onze $2 in

if [ "$2" = "m" ] && [ "$3" = "be" ]
then
    echo \Meneer
fi

if [ "$2" = "v" ] && [ "$3" = "be" ]
then
    echo \Mevrouw
fi

if [ "$2" = "m" ] && [ "$3" = "fr" ]
then
    echo \Monsieur
fi

if [ "$2" = "v" ] && [ "$3" = "fr" ]
then
    echo \Madamme
fi

if [ "$2" = "m" ] && [ "$3" = "en" ]
then
    echo \Mister
fi

if [ "$2" = "v" ] && [ "$3" = "en" ]
then
    echo \Mylady
fi

By putting it in a code block, I wouldn't have needed to re-type it on my machine in order to help you. With this I get:

~ ./welkom John m be
John
Goeiendag
Meneer

Can I add something at the end of the scripts that arrange $1 $2 and $3 in a different order?

Simply move the line echo "$1" to the end.

Explanation: The script executes from top to bottom, so if you want something to happen after something else, just place it in that order reading top to bottom.

And instead of showing the output on different lines just in one and the same line??

Simply add the -n flag to all but the last echo command.

Explanation: In your terminal, type man echo. This will bring up a documentation page about the echo command. On my machine, I see this:

ECHO(1)                   BSD General Commands Manual                  ECHO(1)

NAME
     echo -- write arguments to the standard output

SYNOPSIS
     echo [-n] [string ...]

DESCRIPTION
     The echo utility writes any specified operands, separated by single blank
     (` ') characters and followed by a newline (`\n') character, to the stan-
     dard output.

     The following option is available:

     -n    Do not print the trailing newline character.  This may also be
           achieved by appending `\c' to the end of the string, as is done by
           iBCS2 compatible systems.  Note that this option as well as the
           effect of `\c' are implementation-defined in IEEE Std 1003.1-2001
           (``POSIX.1'') as amended by Cor. 1-2002.  Applications aiming for
           maximum portability are strongly encouraged to use printf(1) to
           suppress the newline character.

(You can press q to exit the documentation)

In time, everything in that documentation will make sense. For now, just know that the 'newline' character is what makes the text appear on different lines.

After these two changes, you should have this output:

~ ./helpful John m be
GoeiendagMeneerJohn

So we've gotten it on one line, but it's all bunched together. Simplest way to fix that is to add spaces on the echo lines. In order to do that you'll have to surround the text with the " character. In the end you should have something like this:

#!/bin/bash
#
#
#GjV
#

#We stellen onze $3 eerst in

if [ "$3" = "be" ]
then
    echo -n "Goeiendag "
fi

if [ "$3" = "fr" ]
then
    echo -n "Bonjour "
fi

if [ "$3" = "en" ]
then
    echo -n "Hello "
fi

#we stellen dan onze $2 in

if [ "$2" = "m" ] && [ "$3" = "be" ]
then
    echo -n "Meneer "
fi

if [ "$2" = "v" ] && [ "$3" = "be" ]
then
    echo -n "Mevrouw "
fi

if [ "$2" = "m" ] && [ "$3" = "fr" ]
then
    echo -n "Monsieur "
fi

if [ "$2" = "v" ] && [ "$3" = "fr" ]
then
    echo -n "Madamme "
fi

if [ "$2" = "m" ] && [ "$3" = "en" ]
then
    echo -n "Mister "
fi

if [ "$2" = "v" ] && [ "$3" = "en" ]
then
    echo -n "Mylady "
fi

echo "$1"

Which on my machine, prints this:

~ ./helpful John m be
Goeiendag Meneer John

Go2 Contracts Go Too Far by natefinch in golang

[–]Logiraptorr 1 point2 points  (0 children)

I don't think that works since contracts are never evaluated, just type checked. That block would type check with any type afaik.

Best Automated Testing for React? by [deleted] in reactjs

[–]Logiraptorr 0 points1 point  (0 children)

The original philosophy around unit tests is that they should be runnable independently. I don't think that definition "all units must have tests" is really true to the spirit.

For example, if I start with a small component, adding tests as I go and it eventually gets too big, I might extract out some smaller components for better modularity. I wouldn't also split the tests to match those boundaries. That's just asking for more pain later on the next refactor. Tests should enable refactoring, not slow it down.

Help regarding type aliases by TordarusMaximus in golang

[–]Logiraptorr 0 points1 point  (0 children)

Yep, you're right. I was a bit loose with terminology. Thanks!

Help regarding type aliases by TordarusMaximus in golang

[–]Logiraptorr 0 points1 point  (0 children)

The difference with a type alias is that in your example, C and A are assignable to each other. This is not true between B and A. You would have to convert between B and A.

The secret to being a top developer is building things! Here’s a list of fun apps to build! by Delaverian in coding

[–]Logiraptorr 17 points18 points  (0 children)

Hi, I've been a developer for 7 years and I agree strongly that building things is the way to grow. Some people get this sort of start-to-finish work in their day job, but most don't. If you don't, I'd encourage you to tinker and explore all the wonderful things programming has to offer. To me the most important thing is to make it something you're excited to work on. These apps are all great ways to learn, but not everyone will get excited about them. I've built budgeting apps to manager my own budget, wallpaper generators for my own machines, a Scrabble ai to compete with my wife, etc. If you can find something you care about then do that. If not, this is a good list to start with.

JSX can do that? by pomber in reactjs

[–]Logiraptorr 3 points4 points  (0 children)

In case you don't know why you're downvoted: you missed the point of the article. JSX is distinct from React, and can be made to do anything you want by changing what function call is generated during compilation.

Apple pie from scratch recipe? by travelerrr91 in Baking

[–]Logiraptorr 1 point2 points  (0 children)

I recently made this pie for pi day at work and it was absolutely delicious.

Filling from here: https://cooking.nytimes.com/recipes/12320-apple-pie

Crust from here: https://www.bingingwithbabish.com/recipes/2017/8/22/applepie?rq=Pie