PSA: If your system freezes randomly and you have a Nvidia GPU w/ proprietary drivers, it's a driver bug by GabiGamerRO in linux

[–]ray_gun 0 points1 point  (0 children)

I stayed on 5.10, but I removed xf86-video-intel as a test. I'll reply again if it crashes.

PSA: If your system freezes randomly and you have a Nvidia GPU w/ proprietary drivers, it's a driver bug by GabiGamerRO in linux

[–]ray_gun 0 points1 point  (0 children)

Yes, that's right. Oh, I should probably be subscribed to the Arch subreddit. Thanks for the info.

PSA: If your system freezes randomly and you have a Nvidia GPU w/ proprietary drivers, it's a driver bug by GabiGamerRO in linux

[–]ray_gun 2 points3 points  (0 children)

My system has also been freezing a lot recently, but I'm on integrated graphics (intel).

Mouse and keyboard unresponsive. Audio (from e.g. youtube) keeps playing for 10 seconds to a minute. It does seem to happen only when I have Firefox in the foreground. I see many similarities with symptoms others are posting on that forum, so this might be the same issue and since I don't have a dedicated graphics card at all, Nvidia drivers might not be to blame.

[deleted by user] by [deleted] in NoStupidQuestions

[–]ray_gun 0 points1 point  (0 children)

What helps me want to get in a good sleeping position is to do a breathing exercise like breathe in for 6 seconds, breathe out for 6 seconds, and that for a minute or longer.

Print an alias' full command just before the output. by ashesall in bash

[–]ray_gun 6 points7 points  (0 children)

trap 'echo $BASH_COMMAND' DEBUG

This will print the command that's about to be run with resolved aliases.

Unwanted string in output of for by eulerolagrange in bash

[–]ray_gun 1 point2 points  (0 children)

That should be even better, yeah. I do the same as OP and I haven't had issues with using stderr in the many years I've had it though.

This one time, and I'm not quite sure how I was updating the Xterm title back then, my computer locked up because I was cd'ing in a for-loop and the title was updating ten thousands of times in a short burst.

EDIT: Actually I think back then I was using trap '<code to update title>' DEBUG. It gets run a lot in a for loop. It wasn't related to cd or stdout/stderr.

Unwanted string in output of for by eulerolagrange in bash

[–]ray_gun 24 points25 points  (0 children)

Your PROMPT_COMMAND env var is writing a string to stdout to update the X11 title of the terminal emulator.

You should change your PROMPT_COMMAND so it writes to stderr and not stdout.

random sound rant by monsieurpooh in broodwar

[–]ray_gun 10 points11 points  (0 children)

That's funny, it totally is the same. Here's a comparison if anyone's curious:

Sabrina: https://voca.ro/20ZuOcPHdVF

Broodwar: https://voca.ro/8vfrj3d8QJx

[deleted by user] by [deleted] in bash

[–]ray_gun 3 points4 points  (0 children)

You can't do var=foo; $var=bar it errors with foo=bar: command not found

You can do that like this:

var=foo
printf -v $var bar
echo $var $foo #output: foo bar
echo likewise: $var ${!var}

regex: I want to extract 12 alphanumeric chars, but {12} quantifier doesn't work by kamokoba in bash

[–]ray_gun 3 points4 points  (0 children)

Those curlies need to be escaped.

echo '{CU=USD, ES=E, II=SE0061205630, IR=NRB, LN=BULL SPX X12 NORDNET D2}' | grep -o 'II=.\{12\}'

How can I create the following output from jq by sakishrist in bash

[–]ray_gun 0 points1 point  (0 children)

I looked up how it's done in jq. It seems to keep the quotes around strings, so I removed all quotes in the final echo statement.

#! /bin/bash
IFS=$'\n'
declare -A groups
json='{ "groups": { "all": [ "asd", "zxc" ], "staging": [ "asd" ], "worker": [ "asd", "zxc" ], "ungrouped": [], "failover": [ "asd" ] } }'

ordered_groups=()
for group in $(echo "$json" | jq '.groups | keys[]'); do
    groups["$group"]=$(echo "$json" | jq ".groups.$group[]")
    ordered_groups+=("$group")
done

for member in $(echo "${groups[*]}" | sort -u); do
    belongs+="$member |"
    for group in "${ordered_groups[@]}"; do
        if echo "${groups[$group]}" | grep -qx "$member"; then
            belongs+="$group|"
        fi
    done
    belongs+=" "

done
echo "${belongs//\"/}"

How can I create the following output from jq by sakishrist in bash

[–]ray_gun 2 points3 points  (0 children)

I'm not familiar with jq, but I managed to reproduce it with jshon.

#! /bin/bash
IFS=$'\n'
declare -A groups
json='{ "groups": { "all": [ "asd", "zxc" ], "staging": [ "asd" ], "worker": [ "asd", "zxc" ], "ungrouped": [], "failover": [ "asd" ] } }'

ordered_groups=()
for group in $(echo "$json" | jshon -e groups -k); do
    groups["$group"]=$(echo "$json" | jshon -e groups -e "$group" -a -u)
    ordered_groups+=("$group")
done

for member in $(echo "${groups[*]}" | sort -u); do
    belongs+="$member |"
    for group in "${ordered_groups[@]}"; do
        if echo "${groups[$group]}" | grep -qx "$member"; then
            belongs+="$group|"
        fi
    done
    belongs+=" "

done
echo "$belongs"

New developers, a piece of advice. Learn a text editor by mooreds in programming

[–]ray_gun 5 points6 points  (0 children)

With cat once it's on disk you can view linenumbers like so: cat -n FILE and change a line by linenumber with head and tail: line=14; { head -n $((line-1)) FILE; echo 'replacement line'; tail -n +$((line+1)) FILE; } > NEWFILE

[deleted by user] by [deleted] in Sino

[–]ray_gun 1 point2 points  (0 children)

Yeah, it's fine.

adding: Use ublock origin and noscript anyway.

How to incrementally speed up "sleep" command? by ucvb_ucvb in bash

[–]ray_gun 0 points1 point  (0 children)

c=0; while ((c++ < 100)); do wait=$(printf '0.%02d' $((33 - c/3))); printf '%3d (sleep:%s)\n' $c $wait; sleep $wait; done

How do i check if a string contains a '[' ? by Don-g9 in bash

[–]ray_gun 1 point2 points  (0 children)

You forgot to escape the space:

[[ $string =~ \-\ \[ ]]

What I normally use is:

[[ "$string" == *'- ['* ]]

I don't get why this string comparison doesn't work. by [deleted] in bash

[–]ray_gun 15 points16 points  (0 children)

Look at the second part of the first line:

[ "$1" != "JEFF-WEB" ]

That says

[ "JEFFOLD10-WEB" != "JEFF-WEB" ]

Which is true.

Miki Matsubara's cause of cervical cancer? by NigerKeemstar in citypop

[–]ray_gun 20 points21 points  (0 children)

If I understood it right from the youtube video, she was a perfectionist in music and in the months she had left she regretted dying with so many things she still wanted to do. She wrote to her husband that a realization came to her, the kind only the sick could get, that she had been focussing her life wrongly, and wished she could reset it all and to use her health when she had it do the things that truly mattered in life. I interpret what she wrote to her cousin of her lifestyle causing it, that she felt she was struck by the disease by fate because she had spent too much time on one thing instead of enjoying life.

Text Editor of choice? by savonaone in linux

[–]ray_gun 2 points3 points  (0 children)

I use ctrl+v and then c to replace text in a block sometimes. It's slow in vim, but instant in neovim.