WTF Bites


  • Discourse touched me in a no-no place

    @topspin said in WTF Bites:

    Packed structs are going over the network, not pointers.

    That wasn't how I interpreted the post... :/

    Hence the rather selective quotations I used.



  • @Kamil-Podlesak said in WTF Bites:

    Yes, unix shell is usually what I do in most cases, too.

    Unix shell is nicer with proper structured commands and consistent quoting, but it's still duck-tape.

    I suppose powershell would be good option for Windows platform.

    It even works on Linux these days. But so far as I've heard, it leaves perl far behind in being write-only.

    I personally like ansible, but it's limited by selection of good modules (and AWS modules are quite.... not good).

    Agree. Ansible feels like a mix of great idea and a horrible kludge. The basic modules work – except they make snails look damn fast – and the various extensions are often, yeah, good definitely isn't the right word.

    And then there is a lot of places where you end up having to create a kludge of some kind or another. Like just today I needed to pull a config file from the server, because the just installed package writes some important magic tokens there. There is a fetch module for that. Great. But I also need to replace the localhost it refers to itself as with the correct hostname and there is no way now.

    Plus the inconsistent variable names I mentioned upthread (the facts are actually available as e.g. both ansible_facts.hostname and ansible_hostname, but the output from ansible <host> -m setup has ansible_facts.ansible_hostname).

    The AKS modules are also not that good, plus for management of clouds the inventory is behaving … well, I didn't actually study it yet (and I hopefully won't; AKS is just one object and then I just use helm).

    @Kamil-Podlesak said in WTF Bites:

    And chicken is a dinosaur.

    Well, it is.


  • Banned

    @Kamil-Podlesak said in WTF Bites:

    But batch file? Yes, it's shell, I suppose. And chicken is a dinosaur.

    I've yet to use any shell feature more complicated than a for loop in any of the shell scripts I've written in my career. Batch can pipe, batch can branch on error code, what more do you need? If you think your script couldn't be written as a batch file of comparable complexity, either you're being a snob and it clouds your judgement, or it should've all been done in Python to start with.


  • Discourse touched me in a no-no place

    @Gąska said in WTF Bites:

    I've yet to use any shell feature more complicated than a for loop in any of the shell scripts I've written in my career.

    I present a for loop (the previous 50% of this script was comments explaining what this does, and why,for the benefit of people who will naturally never read them.)

    # available disks (excluding partitions)
    disks=$(lsblk --output KNAME,TYPE | grep disk | cut -d' ' -f1)
    
    output=0
    for d in ${disks}; do
        if [ "${disk}" == "${d}" ]; then
            udevadm info --query=property --name=/dev/${d} | sed -n 's/ID_SERIAL=\(.*\)/\1/p'
                    output=1
        else
            if [ -z "${disk}" ]; then
                            echo -n "${d}: "
                            udevadm info --query=property --name=/dev/${d} | sed -n 's/ID_SERIAL=\(.*\)/\1/p'
                    output=1
            fi
        fi
    done
    
    if [ ${output} -eq 0 ]; then
            if [ -e /dev/${disk} ]; then
                    echo "/dev/${disk} is likely a partition, not a disk"
            else
            echo "${disk} not found"
            fi
    fi
    

    I thought about presenting the one with arrays, but thought better of it.

    Oh, sod it - the array:

    
    # Files to copy
    declare -A files=(
            # [<source>]=<dest>
            [${fleet_yaml}]=./${TMP}/opt/foo-collector/main.yaml
            [./resources/hostlist_small.shuf]=./${TMP}/opt/foo-collector/hostlist.txt
            [${RELEASE_DIR}/release/foo-collector]=./${TMP}/opt/foo-collector/
            [./<peculiar>.json]=./${TMP}/opt/foo-collector/
            [./cacert.pem]=./${TMP}/opt/foo-collector/
            [./scripts/S99foo-collector]=./${TMP}/etc/rc.d/rc3.d/
            [./scripts/foo_race.sh]=./${TMP}/opt/foo-collector/
    )
    for source in "${!files[@]}"; do
    ...<copy stuff to distrib directory to be further tar'd>
    

    Oooh, look - another for loop...


  • Banned

    @PJH as I said, I've yet to use any shell feature more complicated than a for loop. That implies I have used for loops. But batch can do for loops as well. Yes, everything gets 4x more verbose, but it's not that hard.


  • :belt_onion:

    @Gąska

    foreach stuff
    
    hcaerof
    

  • BINNED

    @Gąska said in WTF Bites:

    @PJH as I said, I've yet to use any shell feature more complicated than a for loop. That implies I have used for loops. But batch can do for loops as well. Yes, everything gets 4x more verbose, but it's not that hard.

    But even basic stuff like for loops and branches are horribly kludgy in batch files. You can pull off the same thing as in shell scripts, but it gets hard and hacky very fast.


  • Trolleybus Mechanic

    @Gąska said in WTF Bites:

    Batch can pipe, batch can branch on error code

    Too much water? Is time for BIG batch.


  • Java Dev

    @PJH said in WTF Bites:

    Why are pointers going over a network?

    Packets go over the network. Packets are written into a 4-byte aligned buffer. All common protocols are designed for their headers to be multiples of 4 bytes long, and align their fields based on that. With one major exception: The bottommost one, ethernet, is either 14 or 18 bytes long depending on whether vlans are in use.

    So IPv4, IPv6, TCP, and UDP packets are virtually always misaligned by 2 bytes in the buffer, pretty much regardless of what options are attached to any of them. And @dkf's probably got pointers to that.

    Of course, the obvious solution to that is to misalign the initial write in the buffer.


  • Banned

    @topspin said in WTF Bites:

    @Gąska said in WTF Bites:

    @PJH as I said, I've yet to use any shell feature more complicated than a for loop. That implies I have used for loops. But batch can do for loops as well. Yes, everything gets 4x more verbose, but it's not that hard.

    But even basic stuff like for loops and branches are horribly kludgy in batch files. You can pull off the same thing as in shell scripts, but it gets hard and hacky very fast.

    Either you're done before you vomit, or your script is complex enough that not using an actual programming language (you know, one that doesn't default to treating every string as a path to program that has to be run) is a massive disservice to whoever is going to maintain your project when you're gone.


  • BINNED

    @Gąska said in WTF Bites:

    @topspin said in WTF Bites:

    @Gąska said in WTF Bites:

    @PJH as I said, I've yet to use any shell feature more complicated than a for loop. That implies I have used for loops. But batch can do for loops as well. Yes, everything gets 4x more verbose, but it's not that hard.

    But even basic stuff like for loops and branches are horribly kludgy in batch files. You can pull off the same thing as in shell scripts, but it gets hard and hacky very fast.

    Either you're done before you vomit, or your script is complex enough that not using an actual programming language (you know, one that doesn't default to treating every string as a path to program that has to be run) is a massive disservice to whoever is going to maintain your project when you're gone.

    How does that change the fact that the threshold where it makes sense to switch to a different language that sucks less is much lower for batch files than for Unix shell scripts?


  • Banned

    @topspin except it's not. You're just more willing to deal with Bash bullshit than with batch file bullshit.


  • Notification Spam Recipient

    @Gąska said in WTF Bites:

    @topspin except it's not. You're just more willing to deal with Bash bullshit than with batch file bullshit.

    Hehe, reminds me of when I made a customizable launched batch script. It drew box art, dynamically determined list items based on whether the target program existed or not, allowed you to customize the arguments string and save it back to the config... Fun times, especially when limited to using just for and set and delayed expansion wasn't a thing....


  • 🚽 Regular

    @PJH posted in WTF Bites an embed which said:

    Man Accidentally Deletes His Entire Company With One Wrong Command - It's FOSS

    If I didn't follow through the link, I never would have realized "It's FOSS" is the name of the site and not part of the headline.



  • @Zecc Ok, Blakey.



  • @Gąska said in WTF Bites:

    topspin except it's not. You're just more willing to deal with Bash bullshit is just documented better than with batch file bullshit.



  • @topspin said in WTF Bites:

    @Gąska said in WTF Bites:

    @PJH as I said, I've yet to use any shell feature more complicated than a for loop. That implies I have used for loops. But batch can do for loops as well. Yes, everything gets 4x more verbose, but it's not that hard.

    But even basic stuff like for loops and branches are horribly kludgy in batch files. You can pull off the same thing as in shell scripts, but it gets hard and hacky very fast.

    Yeah, batch gets messy. I moved to VBScript back around 2000, which has its own issues but I liked it. Still haven't gotten around to learning PowerShell.

    About the only batch files I write nowadays are for running games inside DOSBox, just like the ones I wrote back in the actual DOS days. 🕹


  • Banned

    @Watson said in WTF Bites:

    @Gąska said in WTF Bites:

    topspin except it's not. You're just more willing to deal with Bash bullshit is just documented better than with batch file bullshit.

    Except it's not. You're just more willing to deal with manpages than MSDN. Admit it - you just hate Bill Gates, that's all.



  • @Gąska said in WTF Bites:

    MSDN

    ITYM Microsoft Docs? :half-trolleybus-br:


  • Banned

    @cvi I need to update my bookmark then.



  • Don't bother - MS will reorganize everything in 3 months or so, breaking all your bookmarks :half-trolling:



  • @Gąska
    Nah, just remember the time I had to find out how to echo a literal ampersand.


  • 🚽 Regular

    @Gąska said in WTF Bites:

    @cvi I need to update my bookmark then.

    Your documentation is just where you've left it.



  • @Zecc said in WTF Bites:

    If I didn't follow through the link

    I didn't...

    I never would have realized "It's FOSS" is the name of the site and not part of the headline.

    I assumed it was deleted because of FOSS...

    I prefer my version.





  • @Polygeekery said in WTF Bites:

    Employee of client is currently emailing Helpdesk because she has pictures from some conference on her phone and wants to print them in the office. Her printer at home can print via Bluetooth and it seems to be blowing her mind that the large professional Kyocera workstation printers in the office can't do that.

    ... and that bluetooth does not work over that 10 miles distance from her home to the office ...



  • @cvi said in WTF Bites:

    @Gąska Here you go. 🐠

    No, I don't go.

    Filed under: Warning: Bing search link

    Not there.



  • 1497fae4-b810-4515-8de7-79830adadeed-image.png



  • @Gąska said in WTF Bites:

    Either you're done before you vomit, or your script is complex enough that not using an actual programming language (you know, one that doesn't default to treating every string as a path to program that has to be run) is a massive disservice to whoever is going to maintain your project when you're gone.

    Ok, looks like this got quite derailed, so let's return back to the square one: Any script that does "deploying to EC2" is already quite deep in the category "should be done in actual programming language".

    Using unix shell on unix (or linux) and its quite wide range of utilities makes it quite manageable, but you will definitely need some extra ones. At the very least, something to manipulate and parse JSON is quite necessary. These scripts often end up using perl or python snippets.

    Using windows batch file with no extra utilities is definitely WTF and the "ping" as poor-man's "sleep" is probably just a tip of iceberg. Using unix shell in these circumstances (EC2 deployment on windows, with no extra utilities) would be actually even bigger :wtf:



  • @Bulb said in WTF Bites:

    What would be your suggestion?

    Our operations department use Ansible. We're mostly AWS but we have some Azure capability too.

    Edit: Posted before I saw the thread got derailed, but I'm leaving this here because it might be useful


  • Discourse touched me in a no-no place

    @PJH said in WTF Bites:

    Why are pointers going over a network?

    It's a pointer into the message that's going out over the network, and the format of the protocol (already layered on top of UDP) is one that doesn't sit nicely with C. The problem is that the message has a variable width header followed by a payload that is a sequence of either uint16_t or uint32_t. The variable width header is such that sometimes the values in the payload are aligned, and sometimes they aren't.

    It's ghastly. It's designed to be pretty easy to pack and unpack in Python code, but in C it's just horrid.

    If we were to redo it (which would require lots of testing because it is going through part of the hardware where we at least sometimes have bandwidth limits) we'd turn the header into something fixed width and probably only ever use uint32_t for the payload values. By nailing down the actual alignment assumptions, I at least only have two writes per word (into the queue of packets to be sent, which is stored in SDRAM and so is comparatively slow) rather than four…

    And of course the protocol concerned has third-party clients too. Why wouldn't it? 🍊

    @PJH said in WTF Bites:

    And apart from that question - did no one think of this?:

    FWIW, I'm doing stuff that's beyond what that (good!) article covers. 😜 I also have a super-fixed target (fixed architecture, mostly fixed compiler) so I don't care about portability.


  • Discourse touched me in a no-no place

    @Zerosquare said in WTF Bites:

    @PJH said in WTF Bites:

    Why are pointers going over a network?

    Isn't @dkf working on a machine where "network" is means "communication with other nodes of the same machine"?

    Yes, but in this case it's talking to the outside world over UDP. (The internal network only moves messages consisting of one or two user-specified machine words.)


  • Discourse touched me in a no-no place

    @PJH said in WTF Bites:

    Only useful if you have sufficient control over the environment that you can guarantee one executable on one box has the same memory mapping as that of another machine.

    Machine A: Here, have some data $X and store it in $ADDR.

    Machine B: OK, I'll go stick it in $ADDR

    Unless it's a very controlled environment, I can't see how that's even a.. thing?

    We can guarantee it. We have full control over the stack from the hardware macrocell level up (and even lower than that in some parts of the hardware). We do actually send addresses about, but that's usually either for debugging or because we're doing data movement (as part of the control system saying “load this big array into memory right there”.) The protocol I'm grumbling about is mostly used for runtime tracing these days; we have faster ways of doing other operations (which depend on the actual simulator code not running to be efficient).


  • Discourse touched me in a no-no place

    @PleegWat said in WTF Bites:

    @PJH said in WTF Bites:

    Why are pointers going over a network?

    Packets go over the network. Packets are written into a 4-byte aligned buffer. All common protocols are designed for their headers to be multiples of 4 bytes long, and align their fields based on that. With one major exception: The bottommost one, ethernet, is either 14 or 18 bytes long depending on whether vlans are in use.

    So IPv4, IPv6, TCP, and UDP packets are virtually always misaligned by 2 bytes in the buffer, pretty much regardless of what options are attached to any of them. And @dkf's probably got pointers to that.

    Of course, the obvious solution to that is to misalign the initial write in the buffer.

    We have a whole separate load of stuff to deal with that that's part of the embedded OS (running on a different core). The code I was talking about was doing higher-level message assembly in a buffer that was initially aligned, and the real problem is that the protocol whose message this is is itself horrible. (Its original authors no longer work for us.)


  • Notification Spam Recipient

    @Kamil-Podlesak said in WTF Bites:

    just a tip of

    Oh I just can't wait to get deeper.


  • Banned

    Yesterday, YouTube comments stopped showing up for me so I decided to remove all caches of that website. Fortunately, Firefox has the "forget about this site" feature. It took about 10 minutes, during which CPU utilization was at 50% and RAM usage by Firefox hit 8GB - if I didn't run out of RAM, it'd probably be even higher. And the browser was nearly completely unresponsive, which I find even worse than being completely-completely unresponsive. The funniest part was that an alert popped up that a JS script is making everything slow and whether I want to terminate it.


  • Notification Spam Recipient

    @Gąska said in WTF Bites:

    YouTube

    Status: perfection.

    Screenshot_20200615-081607_YouTube.png



  • 8fa270e4-816b-412e-b55b-eaa42fac782f-image.png

    So, VS Code's help text says, for getting started with Java, if the folder you open has a build.gradle file in it, VS Code will do whatever magic and treat the whole folder as the project.

    Yet, there is a build.gradle file in said folder and every java file in the folder gives the error "[this file] is a non-project file" anyways. All of the gradle tasks seem to work fine, but hitting F5 just breaks with "the project [name] is not a valid java project" and links to a Github page about "failed to resolve classpath" which doesn't give me a usable answer.



  • The problem is that MCP Gradle files do a lot of obscure magic to try to:

    1. Deobfuscate Minecraft and add that to your classpath for e.g. Intellisense
    2. Transform your code that refers to identifers in deobfuscated Minecraft to refer to the same members using the identifiers from retail Minecraft
    3. Compile that transformed code, using special settings that let you take advantage of Java 8 syntax improvements while emitting Java 6 compatible class files
    4. Package everything "neatly" into a JAR suitable for plopping in a Forge "mods" folder.

    The normal "build Java" task doesn't even exist in that Gradle file, which is why VSCode has no idea what files are in your project or not.



  • @TwelveBaud Amazing, because 24 hours ago, I wasn't getting those error messages (but instead, had working intellisense) and hitting F5 "just worked".





  • @TwelveBaud That's how I think I should feel. How I actually feel:

    dc79ccf7-da88-48ae-8479-55d4c121356e-image.png

    EDIT: I just realized, it's the same level of :wtf: I feel when, at work, Visual Studio suddenly believes it needs a newer version of Mono installed on the Mac despite VS 2019 on both the Mac and my desktop not having updated in a few months.



  • @ChaosTheEternal
    So Visual Studio is like a cat. Sitting in your lap contentedly purring as you stroke it. Then, for whatever reason, it decides "BORED NOW" and sinks its teeth into your thumb before stalking off.


  • Discourse touched me in a no-no place

    @Watson said in WTF Bites:

    sinks its teeth claws into your thumb tes… thigh

    FTFY



  • Time for another desk flip, as 15 hours later, without changing a thing, I open VS Code again and "it just works" now. I get the proper intellisense and F5 runs the proper task with debugging.

    The only changes between then and now is I hibernated my computer overnight and am on my work VPN now (but that's a split VPN so nothing from VSCode or my other browsing should be using that connection).


  • BINNED

    Holy shit, I hate badly implemented two-factor garbage.

    Tried to order a camera online and pay with my Visa card. Enter my CC number and the CVC code (i.e. the usual wish-it-was-two-factor) and off we go. But wait, the EU at one point decided that's not secure enough so it needs some verification with "Visa secure 3-D Secure secure™".

    Sure, I've gone through that hell already before, so this should all be registered and set up. The Visa site told me it's sent a verification code to my phone and I need to open the bank's "ID check" app to accept it. Easy as that. Or maybe not, maybe it's a fucking nightmare.

    I check the phone, there are no push notifications. Okay, no worries, who knows how that works. I open the app that I had previously registered the CC with. It doesn't show the code. In fact, it doesn't even show the CC. Sigh
    So I click to register the card again with the app. It helpfully tells me that, for verification, it sent a code to my previously registered phone. What fucking phone? This phone?! Well, obviously that didn't get through. I click the button to re-register with a new phone in case I don't have access to the originally registered one (I do but :rolleyes:).

    Next, it asks me for my online banking login information (account number and password). As I enter that, the app tells me (in one half-sentence banner notification that disappeared after 3 seconds) that I need to switch out of the app to online banking in a browser to enter a TAN number (because, it turns out, I haven't used any online banking that required a TAN in several weeks and so I needed to reactivate that). Done, back to registering the card.
    It wants me to pick between chipTAN variants (optical, QR code, manual). Wait, I thought I was trying to register a card for the phone app thing, not a chipTAN generator?! Oh, I got it, I need to enter another TAN, this time actually inside the app and not an external browser, and it asks me for the choice there. Next, it explains that I need to put the card in the TAN generator, enter a "start code", enter the last 4 digits of the card number, and enter the resulting TAN. I tried that and nothing happens. It reloads the screen, I retry this shit (having to enter the CC number again) being extra careful not mistype anything, and it fails again without error message. Third time's the charm, but this time it doesn't even let me try but tells me that I need to switch back to online banking again to "synchronize the TAN generator". What? What the fuck does that even mean?! I search for that shit in their online banking website and find instructions how to do it. It tells me I need to make sure to have the right card in the generator ("*****12345"), which makes me pause for a moment. That's not the CC number, but also not the account number for my bank card. Oh, it's the actual serial number for my bank card, which is printed on the back and I have never used before. At this point I can synchronize the stupid TAN generator and also realize the mistake I made earlier:
    The page in the app that asked me for a TAN talked about the credit card ("the last 4 digits" etc.") but I should have used the bank card to actually generate that TAN. The TAN generator, of course, worked just fine with the CC instead and the app was too fucking retarded to either spell out that there's two different cards involved in that instruction text or to give me an error message what the fuck went wrong.

    I have now successfully registered the card, again! And it only took me 30 minutes! Don't know if this garbage actually works, though, as I have already paid with PayPal in the meantime.

    Brave New World!


  • Banned

    @topspin my experience with 3-D Secure has been great - probably because instead of some shitty app, I just get sent an SMS code that I have to enter. Works flawlessly every time. Except when a particular shop doesn't require 3-D Secure at all, in which case payment gets made without any confirmation. Which defeats the entire purpose of 3-D Secure in my eyes.


  • BINNED

    @Gąska said in WTF Bites:

    @topspin my experience with 3-D Secure has been great - probably because instead of some shitty app, I just get sent an SMS code that I have to enter. Works flawlessly every time. Except when a particular shop doesn't require 3-D Secure at all, in which case payment gets made without any confirmation. Which defeats the entire purpose of 3-D Secure in my eyes.

    Well, yeah, that would be too simple to get wrong. So of course I have to deal with complicated and buggy garbage instead.

    Why it's for the shop to decide whether to use this I don't understand either.


  • Discourse touched me in a no-no place

    @topspin said in WTF Bites:

    Why it's for the shop to decide whether to use this I don't understand either.

    I thought it was decided by the payment provider?


  • BINNED

    @loopback0 I'm not sure.


Log in to reply