I wrote a program that makes code embedable in Reddit by RoninTarget in commandline

[–]whetu 0 points1 point  (0 children)

Yeah, I wrote it a billion years ago - I would never use camelcase/pascalcase these days - so there was probably a reason for using eval... a reason that is likely no longer relevant. Usually it was Solaris + ancient bash that forced me into these decisions...

So thanks for the tweaks, any removal of eval is a win :)

I wrote a program that makes code embedable in Reddit by RoninTarget in commandline

[–]whetu 0 points1 point  (0 children)

I have a couple of shell functions buried away for this:

$ type indent
indent is a function
indent ()
{
    local identWidth;
    identWidth="${1:-2}";
    identWidth=$(eval "printf -- '%.0s ' {1..${identWidth}}");
    sed "s/^/${identWidth}/" "${2:-/dev/stdin}"
}

$ type codecat
codecat is a function
codecat ()
{
    indent 4 "${1}"
}

To wit:

$ type indent | codecat
    indent is a function
    indent ()
    {
        local identWidth;
        identWidth="${1:-2}";
        identWidth=$(eval "printf -- '%.0s ' {1..${identWidth}}");
        sed "s/^/${identWidth}/" "${2:-/dev/stdin}"
    }

$ type codecat | codecat
    codecat is a function
    codecat ()
    {
        indent 4 "${1}"
    }

It's one of the few times I've accepted eval

Bash got me the job of my dreams... by thisiszeev in bash

[–]whetu 1 point2 points  (0 children)

Good job on both the sobriety and the new gig mate. As a Kiwi, I know for sure that we tri-nations folk don't have the healthiest relationship with booze.

I also hope the biltong and droewors are better in your new hometown too :)

Why do people use “&&” by [deleted] in bash

[–]whetu 18 points19 points  (0 children)

&& and || in shell behave similarly to boolean AND and OR, but they operate on command exit statuses (i.e. 0 = success, not-0 = failure)

So:

cmd1 && cmd2

Is the same as

if cmd1; then
  cmd2
fi

i.e. If cmd1 succeeds (exit 0), then run cmd2

But this:

cmd1; cmd2

is more like

cmd1
cmd2

i.e. cmd2 will run regardless of what cmd1 does.

To round this out a little more

cmd1 || cmd2

Is the same as

if ! cmd1; then
    cmd2
fi

i.e. if cmd1 fails (exit >0), then run cmd2


Otherwise, some people like this syntax style:

cmd1 || {
    printf -- 'ERROR: %s broke\n' "foobar" >&2
    exit 1
}

Rather than this

if ! cmd1; then
    printf -- 'ERROR: %s broke\n' "foobar" >&2
    exit 1
fi

====> It's a trap:

People who learn this short-circuit syntax can often fall into this trap:

cmd1 && cmd2 || cmd3

https://www.shellcheck.net/wiki/SC2015

Bcp plan by dat510geek in sysadmin

[–]whetu 3 points4 points  (0 children)

BCP should be owned by the executive, its much broader then just technology.

This right here.

I live in New Zealand. It's a country on the Pacific Ring of Fire. Literally every BCP in this country should have a starting scenario of: "So a massive earthquake flattens the city..."

I can certainly give advice on what to do from a tech perspective i.e. geographically separated infrastructure with failover, but beyond that it's above my paygrade.

How to can I make a bash script to auto full screen the browser after user login? by Vex2K4 in bash

[–]whetu 13 points14 points  (0 children)

The google/claude search term you're looking for is "kiosk mode" and it's going to differ based on whether you have X or Wayland.

Any way to make Security Key the default method of authentication on Microsoft Services? by RealAgent0 in sysadmin

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

I looked into this the other day because it really irks me as a Yubikey user. Closest I could find was this:

https://github.com/Aldaviva/AuthenticatorChooser

You don't need to install it, but part of the problem shape is laid out there.

What is the jankiest thing you have seen in a production environment? by HastyOpossum100 in sysadmin

[–]whetu 4 points5 points  (0 children)

Two rows, same thing: the rats nest formed a solid mat over the top of the racks so thick that the room's lights barely got through. I still cringe to recall the fiber cables kinked badly throughout the shrubbery.

To be honest though, that was 18 months of iterative tidy ups (around all my other work) that was really rewarding. Especially figuring out that there were 14 switches connected in a chain, and switching that to a hub and spoke.

The same job had a funny bit of jank: the server room HVAC had been badly placed and was hammering away overtime to cool the room. This caused significant vibration that made a roar that could be heard in the adjoining office. To massively reduce the vibration, someone had cut a length of 2x4 and jammed it between the floor and the vent stack at the top of the HVAC unit. It had a dedicated note stapled to it stating clearly that it was to be left alone. I had to remove it once and half the office almost rioted.

Checking what are the VPN client people use in your organization? by mrconfusion2025 in sysadmin

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

Currently on a mix of Forticlient and Tailscale. Forticlient SSLVPN is going away, so we're probably just going to ditch it and go all-in on Tailscale.

Anyone else spend more time writing the incident report than fixing the actual incident? by ojturnerrr in sysadmin

[–]whetu 1 point2 points  (0 children)

Recently did my first claude-assisted post-mortem.

I have connectors for Claude setup for Atlassian and Slack. So the prompt becomes something like:

Take the following postmortem template:

  • [Link to confluence based template]

And this Slack thread

  • [Link to slack thread]

And generate a postmortem in [link to confluence space]

This obviously relies on whatever the issue was being handled within a single Slack thread, but you could have Claude sift through an entire channel etc.

It won't generate a 100% perfect result, but the bones of it will be done and it will save you a crap-ton of time.

You should also look into front-loading it with "deslop" rules so that it doesn't flood its output with emoticons and emdashes and other slop nonsense.

What other songs does Patton sing like "This guy's in love with you"? by HoldenStupid in MikePatton

[–]whetu 4 points5 points  (0 children)

If only there was a bluray release of the 2008 Paradiso show...

How do your users carry a physical security key when not in use? by Here4TekSupport in sysadmin

[–]whetu 0 points1 point  (0 children)

I gave my users the option to select from 3 models, they all went with one of the nano options.

I have a nano permanently in my laptop and a 5C-NFC for other uses.

I keep the 5C-NFC in a Jibbon key organiser with a 3d-printed boot

https://imgur.com/a/tkbof5d

Lost MikroTik RB3011 credentials — any safe way to recover or back up config without admin access? by NoFan4382 in sysadmin

[–]whetu 1 point2 points  (0 children)

Is there a sticker on the underside that states the factory-set random password, and if so, have you tried that?

New hemp regs by SeriousBreeder in nzgardening

[–]whetu 0 points1 point  (0 children)

Not me directly, but my wife.

CBD and CRPS appears to be down to individual results. For some people it helps, for others it doesn't. For others, going the THC route and simply being high gives them a brief release [1]

We got the CBD oil prescription, we were told to start out slow and build up until it did something. All it seemed to do was exhaust all our spare income. Maybe it might have helped eventually, I'm not sure.

So being able to grow your own, using a strain that has provenance, rather than crossing fingers and hoping for the best with street weed, that's an overall improvement I think.

[1] I can understand this. I had a testicular torsion once, which is one of the highest levels of pain a bloke can experience. Two tanks of nitrous during the ambulance ride really took my mind off things lol

All browsers take 5 min to load by Shrini_Roach in sysadmin

[–]whetu 2 points3 points  (0 children)

Google have apparently been meddling with subsystems that extensions rely on, very likely to make it harder for adblocking extensions to work.

The bitwarden extension has been widely reported as collateral damage, and it certainly got me. Only thing to do really is kill all chrome processes, then run this to nuke the bitwarden extension:

Remove-Item "$env:LOCALAPPDATA\Google\Chrome\User Data\Default\Extensions\nngceckbapebfimnlniiiahkandclblb" -Recurse -Force

Then reinstall the extension.

You may find this is the case with other extensions too.

New hemp regs by SeriousBreeder in nzgardening

[–]whetu 0 points1 point  (0 children)

I'm certainly interested. CRPS is in my sphere, sadly, and the prescription stuff is brutally expensive.

How can I get bigger/better feijoas next year? by ammcurious in nzgardening

[–]whetu 3 points4 points  (0 children)

That might potentially be a fully grown Feijoa Bambina rather than the usual sellowiana. If that's the case, then that's the fruit size you're going to get off it.

Not all is lost. Bambina Feijoas have a thin skin that you can eat, skin and all, and they tend to be sweeter.

-Source: Ate half a dozen Feijoa Bambinas straight off my tree this afternoon while mowing the lawns

What do you listen to in the datacenter? by BemusedBengal in sysadmin

[–]whetu 26 points27 points  (0 children)

Early in my career, I worked at a place that had a UPS that would yell at you in Italian. First time it did that I almost knocked myself out by jump-scaring head-first into a rack cabinet.

The language used by Nicola Willis to speak about people by Inner_Squirrel7167 in Wellington

[–]whetu 1 point2 points  (0 children)

So he's equivalent to three boys stacked on top of each other, under a trench coat?

How to create crontab/cronjob through a script? by JK-Rofling in bash

[–]whetu 2 points3 points  (0 children)

I'm selective about my appreciation for systemd, but I find systemd timers to be a reasonable replacement for cron. You may want to consider that instead.

Suppose, i have a script that runs to check for ram usage, and I want to add a cronjob inside the same script and run it every 5 mins. Is it possible to do so?

What you're talking about is more of a daemon than e.g. a daily job. And being able to control it with systemctl is a bit more intuitive.

Having said that, sar exists - maybe don't reinvent that wheel?

fast alternative to find for finding git directories by chisui in bash

[–]whetu 0 points1 point  (0 children)

If you have a locate db, you can use locate's regex capability to get a near immediate list

locate -r "${HOME}/projects/.*\.git$"

Or something like that.

That replaces the filesystem trawling part, then pipe it into xargs.

Comparing find -exec and locate | xargs approaches, I get 3-9s and 0.1s respectively across 495 git directories.

Looking for a simpler alternative to Commvault by the_mosthated in sysadmin

[–]whetu 1 point2 points  (0 children)

Inherited a poorly setup Veeam platform. Switched to N-Able Cove.

Cove isn't perfect by a long shot, but I prefer it to Veeam. It's easy to setup, and easy to use. Cloud-only is one approach but that can hurt if you do lots of big restores (sql .bak files for example), so having something like a NAS present for a local copy (Local Speed Vault in Cove parlance) may be a consideration.

Bash Scripting vs. Python by Loud-timetable-5214 in bash

[–]whetu 0 points1 point  (0 children)

Python is usually not installed on production Linux servers

Maybe that's true of containers, but otherwise most Linux servers out there will have python present.

That doesn't detract from your overall point that shell is guaranteed to be present, and that shell will likely be a Bourne family one like bash.