WTF Bites



  • @BernieTheBernie said in WTF Bites:

    And how can I create SVGs with Razor?

    Since you can basically include SVG in HTML, it should work in whatever templates too, no special support needed. Or, if you don't want to deal with the raw markup, render the image in any .нет svg library and treat the return as dynamic html component.



  • Anyways, there seems to exist a C# library for dealing with SVGs:

    I'll have a look at it.



  • @Bulb said in WTF Bites:

    @BernieTheBernie said in WTF Bites:

    And how can I create SVGs with Razor?

    Since you can basically include SVG in HTML, it should work in whatever templates too, no special support needed. Or, if you don't want to deal with the raw markup, render the image in any .нет svg library and treat the return as dynamic html component.

    I do this sometimes, no point having the round trip for the extra request plus the content if it’s potentially cheaper to just inline it. Though the cost of extra requests is lower if using HTTP/2 or beyond but it’s surprising how few servers are actually set up to do that correctly.


  • Java Dev

    @Arantor said in WTF Bites:

    If in doubt, add yet more XML to your SVG. What’s the worst that could happen?

    $ find -name \*.xml -exec wc {} + | grep total
    

    I cut it off after 9 totals, trending 100k-1M lines and 5-50MB each.



  • @Arantor said in WTF Bites:

    @Bulb said in WTF Bites:

    @BernieTheBernie said in WTF Bites:

    And how can I create SVGs with Razor?

    Since you can basically include SVG in HTML, it should work in whatever templates too, no special support needed. Or, if you don't want to deal with the raw markup, render the image in any .нет svg library and treat the return as dynamic html component.

    I do this sometimes, no point having the round trip for the extra request plus the content if it’s potentially cheaper to just inline it. Though the cost of extra requests is lower if using HTTP/2 or beyond but it’s surprising how few servers are actually set up to do that correctly.

    The main point of including SVG in the HTML directly is that then your CSS applies to it, so it can be made to respect your text and background color and such. Which is useful now when everybody wants theme support in everything with at least a dark and a light theme.

    And you can also add anchors (links) to the embedded SVG, obviating the need for a separate imagemap.



  • @Bulb there’s that too but that’s honestly not the thinking people actually apply. I don’t know if you saw my rant about the time I had to fudge some branding colours in an SVG by manually adding Tailwind classes to it as the only choice I had to style it.



  • @Arantor Yes, I recall something like that. Which is an example of some people applying that thinking (and others not).


  • BINNED

    @Arantor said in WTF Bites:

    the thinking people actually apply

    :doubt:
    </hardwaregeek>



  • @Arantor Also, for a logo, adding styling might be tricky if the designer draws it in some graphics program using specific colors, so having a separate version per theme makes more sense. But when using SVG for icons, especially the modern flat icons that only use the font color, making those respect the font color from CSS is simpler than having multiple versions.



  • @Bulb if only I had had the choice to give it two versions of the logo, hence manually mangling in Tailwind classes to almost get there.


  • Considered Harmful

    @LaoC said in WTF Bites:

    GKartnUX0AA7_ZA.jpg

    Safety first!



  • @BernieTheBernie said in WTF Bites:

    Anyways, there seems to exist a C# library for dealing with SVGs:

    I'll have a look at it.

    In a frist preliminary step, I added a string property to the model which returned an SVG text I copied from the internetz.
    How to get it displayed?
    I added a div to the page:

    <div>
        @Html.DisplayFor(modelItem => modelItem.Svg)
    </div>
    

    Well, it does what it is expected to do: it shows me raw xml instructions on the web page.
    Not exactly what I wanted to achieve,

    What else can I try?
    Ah, there is also an @Html.Raw() directive. Looks great. Let me try it:
    @Html.Raw(modelItem => modelItem.Svg)
    Compile it, and ... voilà:
    error CS8917: The delegate type could not be inferred.
    :wtf_owl:

    After long googelling the internetz, I learned that I must use:
    @Html.Raw(@Model.Svg)
    Note that it says @Model instead of modelItem - the latter is unknown there.
    And then it actually workz.
    :surprised-pikachu:
    That's very logically consistent.



  • Now I was not so content with the style of the tables. I wanted to see "grid lines".
    <table border="1"> does the trick.
    Does it?
    It does?
    :amidala_happy:
    Now, it does not.
    Why tf?
    Because...
    when you create a Razor Äpp with Visual Studio, it automagically includes some css:

    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
    

    And that is a really loooonnnngggg one-liner. More than 164,000 characters in ONE line. And it fucks the rendering of zhe tablez.
    Wounderfool!


  • Considered Harmful

    I'll see your 502 OK and raise you

    8883199d-0a98-43e0-9770-1bfbeacf59dd-image.png



  • @BernieTheBernie said in WTF Bites:

    <table border="1"> does the trick.
    Does it?

    :sideways_owl: Has it ever?

    Now I'm in no way an expert on this stuff, and I wasn't familiar with the border attribute; but as I gather from MSN it's 1) deprecated and 2) equivalent to setting the css border property, which, if memory serves, just draws an outline around the entire table, no grid lines.

    Whenever I wanted a table to look like, you know, a table, I needed at minimum something like the following css:

    table { border-collapse: collapse }
    td, th { border: 1px solid black }
    

  • Considered Harmful

    @BernieTheBernie said in WTF Bites:

    when you create a Razor Äpp with Visual Studio, it automagically includes some css:

    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />

    And that is a really loooonnnngggg one-liner. More than 164,000 characters in ONE line. And it fucks the rendering of zhe tablez.
    Wounderfool!

    If you're using Bootstrap you need table class="table table-bordered" Because :raisins:



  • @ixvedeusi :um-actually: HTML 1.0 or earlier was the current version when I wrote my frist html page, and ... :um-nevermind:

    Yes, when I add your lines to site.css, they override the former mega-line settings.



  • Welcome to Web 2.0!



  • @Arantor said in WTF Bites:

    Welcome to Web 2.0!

    Wait, aren't we at 3 already?



  • @Kamil-Podlesak said in WTF Bites:

    @Arantor said in WTF Bites:

    Welcome to Web 2.0!

    Wait, aren't we at 3 already?

    Yes but a) that fad he’s fighting with is firmly 2.0, while b) Web 3.0 is all about the dApps (distributed apps) and something something blockchain.



  • @Arantor said in WTF Bites:

    Welcome to Web 2.0!

    Or rather Web 2.916.38



  • @BernieTheBernie

    .min.css
    More than 164,000 characters in ONE line.

    :surprised-pikachu:



  • @hungrier Well, .min. means it's all squashed to one line, not how much is squashed there.


  • Notification Spam Recipient

    @BernieTheBernie said in WTF Bites:

    And that is a really loooonnnngggg one-liner. More than 164,000 characters in ONE line. And it fucks the rendering of zhe tablez.
    Wounderfool!

    With comments its probably six lines. :technically-correct:

    It's not completely god-awful but yeah, as @error pointed out, you have to throw away everything you've learned and hope its in the css file. Anything non-standard probably requires a css selector or two. :sadface:

    Bit surprised they didn't force the js on you too.



  • @DogsB Of course, there is also a :airquotes: little amount :airquotes: of JavaScript, too. Like /lib/jquery/dist/jquery.min.js and /lib/bootstrap/dist/js/bootstrap.bundle.min.js. But those few Terabytes are not executed.


  • Notification Spam Recipient

    @BernieTheBernie said in WTF Bites:

    @DogsB Of course, there is also a :airquotes: little amount :airquotes: of JavaScript, too. Like /lib/jquery/dist/jquery.min.js and /lib/bootstrap/dist/js/bootstrap.bundle.min.js. But those few Terabytes are not executed.

    Very webby 2.0. You will probably lose the ability to read and write js if you spend too much time with it.

    Not sure if that is a good thing or a bad thing. :mlp_shrug:



  • @DogsB said in WTF Bites:

    lose the ability to read and write js

    :doubt:
    Why?
    Simple. I do not understand js anyways.
    😜



  • @DogsB said in WTF Bites:

    @BernieTheBernie said in WTF Bites:

    @DogsB Of course, there is also a :airquotes: little amount :airquotes: of JavaScript, too. Like /lib/jquery/dist/jquery.min.js and /lib/bootstrap/dist/js/bootstrap.bundle.min.js. But those few Terabytes are not executed.

    Very webby 2.0. You will probably lose the ability to read and write js if you spend too much time with it.

    Not sure if that is a good thing or a bad thing. :mlp_shrug:

    one of us one of us


  • Discourse touched me in a no-no place

    @Bulb said in WTF Bites:

    @Arantor said in WTF Bites:

    Welcome to Web 2.0!

    Or rather Web 2.916.38

    It's now Web 123.something, because we've been switched to Chrome-style versions while we weren't watching carefully.



  • @dkf That would mean we gave up on ever having what was supposed to be the Web 3.0. Which … yeah, we might not, blockchain's being used for many a wrong thing but I don't think I've seen a use-case to make it really compelling for the mainstream.

    But in case we do get it, we can always fix it up by making it Web 1:3.0.



  • Everyone praises linux package management. "just use the package manager!" they say.

    Except when the major packages I need are not in the main repo but in their own separate repos, each of which uses their own methods for getting the keys, plus a bunch of manual crap. And the documentation is out of date. So they just fail to actually work.

    And then there are a bunch that are completely not set up for scripted installation, but require manual intervention of the "log into this webserver and use the setup wizard, also grab this temporary password from the (unstructured) error logs and stick it here using these console commands..." variety.

    I can feel my sanity slipping away piece by piece, second by second. /rant


  • I survived the hour long Uno hand

    @Benjamin-Hall said in WTF Bites:

    I can feel my sanity slipping away piece by piece, second by second. /rant

    :technically-correct: by posting here you've already proven you have no sanity. HTH HAND.



  • @Benjamin-Hall said in WTF Bites:

    Everyone praises linux package management. "just use the package manager!" they say.

    Except when the major packages I need are not in the main repo but in their own separate repos, each of which uses their own methods for getting the keys, plus a bunch of manual crap. And the documentation is out of date. So they just fail to actually work.

    There was a period of time when most of the interesting software was in Debian and few people ever bothered to publish separate Debian repositories (in part because the Debian packaging tools are a bit … well, you need to read the manual to use them). That time is, unfortunately, gone.

    And then there are a bunch that are completely not set up for scripted installation, but require manual intervention of the "log into this webserver and use the setup wizard, also grab this temporary password from the (unstructured) error logs and stick it here using these console commands..." variety.

    I can feel my sanity slipping away piece by piece, second by second. /rant

    Chocolatey does somehow manage to script vast majority of Windows installers though.



  • @Bulb For reference, here's what I have to do to script the installation of mysql on debian bullseye (running as root):

    apt-get install -y debconf-utils
    
    DEFAULTPASS="<some stuff here>"
    # this sets configuration so the package installer doesn't prompt us (despite being non-interactive...)
    sudo debconf-set-selections <<EOF
    mysql-apt-config mysql-apt-config/select-server select mysql-8.0
    mysql-community-server mysql-community-server/root-pass password $DEFAULTPASS
    mysql-community-server mysql-community-server/re-root-pass password $DEFAULTPASS
    EOF
    
    #get the mysql repository via wget
    wget --user-agent="Mozilla" -O /tmp/mysql-apt-config_0.8.29-1_all.deb https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb;
    
    #set debian frontend to not prompt
    export DEBIAN_FRONTEND="noninteractive";
    
    #config the package
    dpkg -i /tmp/mysql-apt-config_0.8.29-1_all.deb;
    
    #update apt to get mysql repository
    apt-get update
    
    #install mysql according to previous config
    apt-get install mysql-server mysql-client --assume-yes --force-yes
    apt-get update -y -qq > /dev/null
    

    because otherwise the deb packages will prompt for installation guidance. If I wanted a graphical installer, I'd not be using linux on the command line.



  • @Benjamin-Hall said in WTF Bites:

    @Bulb For reference, here's what I have to do to script the installation of mysql on debian bullseye (running as root):

    So I guess it wouldn't work with the mariadb fork?

    apt-get install -y debconf-utils
    
    DEFAULTPASS="<some stuff here>"
    # this sets configuration so the package installer doesn't prompt us (despite being non-interactive...)
    sudo debconf-set-selections <<EOF
    mysql-apt-config mysql-apt-config/select-server select mysql-8.0
    mysql-community-server mysql-community-server/root-pass password $DEFAULTPASS
    mysql-community-server mysql-community-server/re-root-pass password $DEFAULTPASS
    EOF
    
    #get the mysql repository via wget
    wget --user-agent="Mozilla" -O /tmp/mysql-apt-config_0.8.29-1_all.deb https://dev.mysql.com/get/mysql-apt-config_0.8.10-1_all.deb;
    
    #set debian frontend to not prompt
    export DEBIAN_FRONTEND="noninteractive";
    
    #config the package
    dpkg -i /tmp/mysql-apt-config_0.8.29-1_all.deb;
    
    #update apt to get mysql repository
    apt-get update
    
    #install mysql according to previous config
    apt-get install mysql-server mysql-client --assume-yes --force-yes
    apt-get update -y -qq > /dev/null
    

    because otherwise the deb packages will prompt for installation guidance. If I wanted a graphical installer, I'd not be using linux on the command line.

    Well, that's the root password. I don't think mysql can do the process credentials login like postgresql does, so it has to get some. And it does use the standard tools for it.



  • @Benjamin-Hall said in WTF Bites:

    linux package management

    Yeah.

    the major packages I need are not in the main repo but in their own separate repos, each of which uses their own methods for getting the keys, plus a bunch of manual crap. And the documentation is out of date. So they just fail to actually work.

    And then there are a bunch that are completely not set up for scripted installation, but require manual intervention of the "log into this webserver and use the setup wizard, also grab this temporary password from the (unstructured) error logs and stick it here using these console commands..." variety.

    I can feel my sanity slipping away piece by piece, second by second. /rant

    Now you're just repeating yourself. :half-trolleybus-tl:


  • Notification Spam Recipient

    @BernieTheBernie said in WTF Bites:

    That's very logically consistent

    Razor is fun like that.


  • Notification Spam Recipient

    @BernieTheBernie said in WTF Bites:

    And that is a really loooonnnngggg one-liner.

    Get rid of the .min. Though it should be doing that for you automatically, you seem to be missing plugins...



  • @Benjamin-Hall said in WTF Bites:

    Everyone praises linux package management. "just use the package manager!" they say.

    Isn't that another example of our well beloved Cascade of Attention Deficit Teenagers?



  • @BernieTheBernie Have you ever seen the Debian Policy Manual? Nobody with attention deficit can ever manage to learn that thing, and I believe passing an exam on that is still a requirement for getting upload permissions to Debian repositories.


  • Trolleybus Mechanic

    @Bulb said in WTF Bites:

    @BernieTheBernie Have you ever seen the Debian Policy Manual? Nobody with attention deficit can ever manage to learn that thing, and I believe passing an exam on that is still a requirement for getting upload permissions to Debian repositories.

    True. You cannot directly upload unless you are a Debian Developer. Becoming a Debian Developer is a long hard haul.

    Debian has many sub-groups, some on R, some on games, etc. They can help explain how to package. For me, it took a long time, maybe 100 hours, before I could even write coherent questions to the e-mail list. The obtuse packaging and publishing system is difficult but learnable. Any time I had a new question might mean five hours of reading and experimentation. But I accept that, this is software. The Debian teams have always been receptive and helpful.

    Please replace Oracle MySQL with MariaDB. About 4 yrs ago I did this and it was great.


  • Trolleybus Mechanic

    @Gearhead Quick question, outside my expertise, I am not a database expert. When would replacing Oracle MySQL with MariaDB be a problem? My first reaction was stored procedures don't work right but there are column rules and others no? Thank you! -GH



  • @Gearhead said in WTF Bites:

    @Gearhead Quick question, outside my expertise, I am not a database expert. When would replacing Oracle MySQL with MariaDB be a problem? My first reaction was stored procedures don't work right but there are column rules and others no? Thank you! -GH

    I'm not actually sure in this particular case, other than that the installation and behavior is twitchy enough without trying to use an unsupported version of a key dependency.


  • Considered Harmful

    @Gearhead said in WTF Bites:

    @Gearhead Quick question, outside my expertise, I am not a database expert. When would replacing Oracle MySQL with MariaDB be a problem? My first reaction was stored procedures don't work right but there are column rules and others no? Thank you! -GH

    The only instance I've seen where it is a minor problem is monitoring with collectd if you have a collectd that's as outdated as everything tends to be in CentOS—it doesn't find some metrics and spams the logs with errors. The other thing is Atlassian stuff and that can be a major PITA. We ran it with an unsupported MariaDB Galera for several years and it works fine in regular use but the updater always shits the bed. It was always fixable with a bit of SQL and swearing up to Jira 7.something but I never got 7→8 to work.



  • @LaoC said in WTF Bites:

    Atlassian ... major PITA ... Jira

    Enough said.


  • Notification Spam Recipient

    Status: I have the sad.

    bd6abb13-8cd9-4467-bed8-7209b686d1c2-image.png


  • Discourse touched me in a no-no place

    @Tsaukpaetra you missed a redaction[REDACTED]


  • Notification Spam Recipient

    @loopback0 Indeed!



  • WTF of my day (ok, one of them).

    This is something I'd seen before, which was good. Because that meant that it only took me 45 minutes to diagnose the issue and provide a solution to my coworker whose ticket it was. But still.

    We have a piece of software that makes some requests and opens a pair of UDP sockets. Those sockets are authenticated by a janky homegrown protocol (literally called the Janky Session Protocol). This relies on a HLO (hello) message that the server replies to with a hashed token. The client then sends back a LGN (login) with that same token and a salt agreed on earlier. If it matches, the session begins. But it has to match for the entire socket--if I HLO on ephemeral port A and LGN on ephemeral port B, that's a no-go.

    The server has a CNAME DNS record pointed at a load balancer, which has 3 IPs backing it. Of course different connections could get any of those records depending on if they re-look-up the DNS entry each time or not.

    All of this is setup and, while janky, mostly works.

    Now the WTF.

    On macs, the default DNS resolution in NodeJS is to do the lookup once and then cache it at the os level, meaning the client always gets the same remote IP and is happy for the duration of the connection.

    On linux, the default DNS resolution in NodeJS is to do the lookup each and every time a connection attempt is made. Which makes some sense--that's why load balancers exist. But for UDP and sockets, this makes for bad things--it will always get a different IP for each part of the connection.

    As a result, when we're testing the thing even dockerized, it will always succeed on our developer machines and always fail when run from a linux-based EC2 instance. With extremely unhelpful error messages. I didn't notice it until I actually did a tcpdump on the traffic and noticed that the remote IPs were changing (and thus the sockets weren't the same).

    And no, there's no toggle. You have to manually do the lookup and force the connection to use the same IP (basically override the DNS name and do the connection to a specific IP, resolved once manually before you start the socket.


  • Notification Spam Recipient

    @Benjamin-Hall said in WTF Bites:

    But for UDP and sockets

    That's the bizarre part for me. Once the UDP socket is "opened" it shouldn't be "re connecting" (things that don't make sense in UDP world), the socket connection itself maintains the state and IP address it's apparently connecting to.

    Unless you're tearing down the object and recreating the socket for each packet....?


Log in to reply