Help Bites


  • Java Dev

    @Zerosquare said in Help Bites:

    There's more to USB-C power than just wattage.

    I think USB-C power cables have a vendor ID too. Make of that what you will.



  • @Zerosquare said in Help Bites:

    There's more to USB-C power than just wattage. It's actually a :wtf: standard with plenty of variations and options. So compatibility problems are not rare.

    I don't think there's much you can do to solve the problem while keeping your existing dock, unfortunately. A firmware update for the dock and/or the laptop, maybe?

    I tried downloading the firmware update tool for the dock, but apparently I don't have admin privileges on that computer, although I'm supposed to. I guess I'll have to contact IT support for that, some time.

    I had been expecting some kind of compatibility issues, but I figured if everything else worked then power should be relatively straight-forward. Guess not



  • @PleegWat said in Help Bites:

    @Zerosquare said in Help Bites:

    There's more to USB-C power than just wattage.

    I think USB-C power cables have a vendor ID too. Make of that what you will.

    I dunno what effect that would have. Here's the whole picture of the devices that are involved:

    • Dell docking station
    • Dell tablet (working fully with dock)
    • HP laptop (working mostly with dock, but unable* to get power from dock)
    • Dell USBC power brick, working with both computers

    * It also looks like the HP laptop can charge from the dock, but only when it's off. The charging light on the laptop lights up orange (battery < 90%). However, when it's on, the only thing it'll do is blink a few times when connecting the dock cable.



  • @hungrier said in Help Bites:

    • Dell docking station
    • HP laptop (working mostly with dock, but unable* to get power from dock)

    Hmm, I was guessing Dell laptop, because sometimes they can't figure out they can charge from their own power bricks, if it's anything other than the default one, even if it's rated for higher power. Maybe the brick/dock isn't reporting something correctly.

    * It also looks like the HP laptop can charge from the dock, but only when it's off.

    My guess would be that for some reason, it doesn't understand how much power the charger can supply, so it doesn't think it can run and charge at the same time, so it doesn't even try.



  • @HardwareGeek said in Help Bites:

    My guess would be that for some reason, it doesn't understand how much power the charger can supply, so it doesn't think it can run and charge at the same time, so it doesn't even try.

    I think it's something in the handshake between the laptop and dock. With the Dell tablet, the light on the USBC cord from the dock lights up, indicating that it's connected and powering. But with the HP, it doesn't light up, either when it's connected and working (minus power), or when the computer is off and it's charging. I suspect that maybe when it's charging like that it's outputting some minimum amount of power.



  • Every time a sale comes up I remember that I kind of want a new router, but when I look at what's on sale it's usually either total garbage or more than I'd like to pay, and since I only think of it last minute I can't do any in-depth research to figure out what to get. So, what's a good, preferably cheap and preferably available on Amazon Canada, home router these days?


  • Banned

    @hungrier my advice: unless you're visibly bottlenecked by what you have now, don't bother. And if you are, there are basically just two criteria to worry about: whether it supports Wi-Fi standard that's fast enough for you (ac if you're in Europe, g if you're in USA), and whether you can install OpenWRT on it. Only get a router that supports OpenWRT or similar aftermarket firmware, they're just so much better than manufacturer's shit.

    Be careful to carefully check not just model number but also revision of the model before buying. TP-Link makes some good routers, but is notorious for replacing 100% of hardware between revisions while keeping the random numbers that make up the product name the same.



  • @Gąska Right now I've got one router in the basement that's pretty old (from 2012 or so), with DD-WRT. The biggest problem with that one is that the wireless range is craptacular, so for my upstairs I've got an even older router acting as a wifi AP, and everything upstairs is connected to downstairs though power line networking.

    Funny you mentioned TP-Link, since they were pretty consistently badly reviewed, at least among the models I looked at that were on sale.


  • Banned

    @hungrier some 10 years ago, I've got a TP-Link TL-WR841N because it was one of the cheapest things in my local electronics store. It worked great for years, and when I installed Gargoyle, it worked even better. But after learning the hard way that power adapter's polarity is just as important as voltage, I've had to replace it. I picked the same model, and out of the box it was the worst thing ever - it's as if it couldn't deal with 2 wireless connections at once. Thought about installing Gargoyle again, but it turns out it's impossible - they didn't just halve the RAM and Flash size, they also changed the SoC vendor altogether! IN A REVISION!!! There was literally nothing in common with the old one except the model number!


  • Notification Spam Recipient

    @Gąska said in Help Bites:

    g if you're in USA),

    Hey, N is now good enough for most ISPs!


  • Banned

    @Tsaukpaetra well, yes, but so is g. :tro-pop:



  • What does Java do if you call toString() on a null value? NPE? Shows "null"?


  • Discourse touched me in a no-no place

    @Captain Generally blows up with an NPE. If you're worried about that, use Objects.toString(theThingThatMightBeNull) instead.



  • @dkf Thanks. Sadly, I just found out that the premise behind my question was false. (I got asked to debug a Java thing that integrates my SSRS report and is crashing out with

    <html><body><INPUT type="hidden" id="fatalerror" name="fatalerror" value="NULL"></INPUT></body></html>
    

    lol. The test case had a null where there shouldn't be, but it turns out the test case had been deleted and partially reconstructed, thereby wasting two days!)


  • Fake News

    @dkf said in Help Bites:

    @Captain Generally blows up with an NPE. If you're worried about that, use Objects.toString(theThingThatMightBeNull) instead.

    Huh, I guess TIL there's a java.util.Objects class since Java 7 with that feature.


  • Banned

    Immutable linked lists are nice because multiple instances can reuse the same memory if they were created by prepending to the same original list. But I have trouble finding whether the same is true for immutable sets and maps. Is anyone familiar with implementations of these data structures in popular functional languages/libraries? How much reuse can I expect in practice? How is it implemented? Or does every insert create a deep copy?



  • @Gąska check out https://hackage.haskell.org/package/containers-0.6.4.1/docs/Data-Map.html for some documentation how it's done in a modern compiler. Basically, it's done on the heap using a special monad with direct memory access.


  • Banned

    @Captain this isn't much of a documentation :mlp_shrug: unless you mean I should follow the linked papers. Unfortunately they're way too advanced for me to make heads or tails out of, and somehow I doubt they're actually things are implemented in practice (but maybe I'm wrong). Anyway, if direct memory access is needed, I suspect there's some deep magic involved that prevents reusing the existing allocated structures if there's a live reference to the previous state, is that correct?

    Specifically I'm wondering about a case where I incrementally build a large set of, say, 10000 elements one element at a time, but also store each intermediate set in a collection so in the end I have a list of 10000 sets, each between 1 and 10000 in size. Real use case I've had some time ago, and I wonder if going with immutable maps was the right decision.



  • @Gąska Sorry, it's a little hard to track down the good bits: https://hackage.haskell.org/package/containers-0.6.4.1/docs/src/Data.Map.Internal.html

    It's pretty "advanced" Haskell, too, with lots of compiler directives and similar for performance.

    But it's probably irrelevant anyway.

    What language and data structure are you using? Can you read its source code? Are you sure they're "really" immutable?


  • Banned

    @Captain that project was C# and OCaml, but I do a lot of Scala lately, and it's fairly relevant there too. I tried to track down the implementations in all 3 but it's pretty well hidden and extremely dense and, just like the Haskell one, riddles with compiler intrinsics and whatnot (except in C#, but it's not a good implementation anyway). I was hoping there was someone who could answer the high-level questions for me so I don't have to deeply analyze the real code. Like, I never looked up an implementation of a regular hashmap either, but I know its main characteristics pretty well, as it's common knowledge that's easily available everywhere. But with immutable data structures, everything more complicated than a linked list seems to be secret knowledge that nobody wants to share and I don't even know where to look for someone who might.


  • 🚽 Regular

    @Gąska

    FWIW, I think the key word you're looking here for is "persistent".

    Does this help at all? https://immutable-js.github.io/immutable-js/docs/#/Map
    I didn't look at it much tbh but it sounds like it could be what you're looking for.


  • Discourse touched me in a no-no place

    @Gąska said in Help Bites:

    Specifically I'm wondering about a case where I incrementally build a large set of, say, 10000 elements one element at a time, but also store each intermediate set in a collection so in the end I have a list of 10000 sets, each between 1 and 10000 in size. Real use case I've had some time ago, and I wonder if going with immutable maps was the right decision.

    That's very very likely to not share, unless you're going for things with utterly horrible access times. The leaf objects may well be shared though; doesn't matter for small integers, but does matter a lot when they're more complex. I know the Tcl implementation of such things, and that (shallow) duplicates on modification of shared values (so that the language models immutability while not carrying quite the costs involved). That has deep consequences for how the threading model is managed (given that fat global locks are Bad) and in the memory model as well.

    I guess in theory you could use trees to get some of the benefits that such trickery has in linked lists, but I really doubt that it'd be a good plan. And actually keeping every step of the build of the map along the way will pretty much guarantee that you don't see any benefit. It's probably better to regard the way you get the cheap immutable sharing from linked lists as a special case that doesn't apply to anything else.

    @Zecc said in Help Bites:

    Does this help at all? https://immutable-js.github.io/immutable-js/docs/#/Map
    I didn't look at it much tbh but it sounds like it could be what you're looking for.

    That's doing the tree trickery.

    And keeping a reference to each state as a long series of insertions is done will prevent the tree from being rebalanced; it'll be a linked list with all the overhead of a tree! I've experience with such things; the access time costs are absolutely brutal.


  • BINNED

    @Captain said in Help Bites:

    using a special monad

    something something something…

    Hell, I don’t even have to make the joke. Haskell is enough of a joke as it is 🎺



  • Question:

    Any ideas why a monitor would sometimes turn off/show "no cable" but then be fine if you unplugged and replugged the cable? It does it with multiple cables (and different types of input), and it's always the same monitor, an older BenQ 24-inch 1080p one.

    That same monitor occasionally freaks out and just displays snow.

    Sign of hardware failure? It has made several long trips and it's about 5 years old at this point.



  • @Benjamin-Hall No idea. But my 27" LG will do it every once in a while when I wake up my ubuntu system. I have to unplug the HDMI cable, wait for the apps to pop back to the main screen, and then replug. Most of the time that works. When it doesn't, I have to reboot ubuntu. (power cycling the monitor doesn't help)


  • I survived the hour long Uno hand

    @Benjamin-Hall possibly an intermittent electrical issue? Sometimes, during the winter, static discharge between my hands and a pair of headphones can cause the connected computer to stop displaying on the TV it is connected to. Unplugging and reconnecting the HDMI cable gets everything working again. If it doesn't disconnect completely, then I might see a narrow horizontal band of incorrect color appear on the screen temporarily.

    The electrical connection there is Headphones -> powered USB amplifier -> computer -> graphics card -> TV. The USB amplifier, computer, and possibly the TV are plugged in to different outlets in the room, so I've wondered if the static discharge interfered with the ground voltage temporarily.



  • @Placeholder said in Help Bites:

    @Benjamin-Hall possibly an intermittent electrical issue? Sometimes, during the winter, static discharge between my hands and a pair of headphones can cause the connected computer to stop displaying on the TV it is connected to. Unplugging and reconnecting the HDMI cable gets everything working again. If it doesn't disconnect completely, then I might see a narrow horizontal band of incorrect color appear on the screen temporarily.

    The electrical connection there is Headphones -> powered USB amplifier -> computer -> graphics card -> TV. The USB amplifier, computer, and possibly the TV are plugged in to different outlets in the room, so I've wondered if the static discharge interfered with the ground voltage temporarily.

    It's plugged into the same computer and same power strip as the other monitor, which doesn't have those issues.

    @dcon I'd expect something weird at startup (my setup is rather frankensteined), but no, it's at random and inconsistent times throughout the day.


  • I survived the hour long Uno hand

    @Benjamin-Hall said in Help Bites:

    it's at random and inconsistent times throughout the day.

    My issue happens only a few times a year, so that does sound like it could be a different cause.



  • @Placeholder said in Help Bites:

    @Benjamin-Hall said in Help Bites:

    it's at random and inconsistent times throughout the day.

    My issue happens only a few times a year, so that does sound like it could be a different cause.

    Some times it doesn't happen. Sometimes it happens a couple times in a given day. Magic gremlins is my guess.


  • Notification Spam Recipient

    @Benjamin-Hall said in Help Bites:

    Any ideas why a monitor would sometimes turn off/show "no cable" but then be fine if you unplugged and replugged the cable?

    I would blame HDCP.



  • @Tsaukpaetra said in Help Bites:

    @Benjamin-Hall said in Help Bites:

    Any ideas why a monitor would sometimes turn off/show "no cable" but then be fine if you unplugged and replugged the cable?

    I would blame HDCP.

    Is there any workaround? It doesn't seem correlated with any media usage, as I'm rarely using media on my work laptop (mac) which is where it shows up the most.


  • Notification Spam Recipient

    @Benjamin-Hall said in Help Bites:

    @Tsaukpaetra said in Help Bites:

    @Benjamin-Hall said in Help Bites:

    Any ideas why a monitor would sometimes turn off/show "no cable" but then be fine if you unplugged and replugged the cable?

    I would blame HDCP.

    Is there any workaround? It doesn't seem correlated with any media usage, as I'm rarely using media on my work laptop (mac) which is where it shows up the most.

    Other than physically reorient the monitor with one that does not have this problem (and swapping their cables, assuming dual-monitor) to double-check it's the monitor proper? I don't really know.

    I had to mess with this Acer 4K monitor (and it still has troubles) like that so it would stop being too buggy to use.


  • Discourse touched me in a no-no place

    @Benjamin-Hall said in Help Bites:

    Sign of hardware failure?

    Could be a dodgy cable. If one of the conductors is broken but still making contact most of the time then things can work… until they don't and everything freaks out. Unplugging and replugging flexes the cable and the connection works again for a while. I mention this because I had this with an ethernet cable a few years back and I thought I was being targeted by problems from my ISP for ages until I swapped the cable for another…


  • Considered Harmful

    @Gąska said in Help Bites:

    Immutable linked lists are nice because multiple instances can reuse the same memory if they were created by prepending to the same original list. But I have trouble finding whether the same is true for immutable sets and maps. Is anyone familiar with implementations of these data structures in popular functional languages/libraries? How much reuse can I expect in practice? How is it implemented? Or does every insert create a deep copy?

    I have the same recommendation you got but substituting the Scala collections for the Haskell collections.



  • Can someone explain to me how T-SQL handles line breaks in a string? I'm working on a fix, and the task is to replace

    XXXX X. XXXX
    Foo: Bar
    So: check

    with

    YYYY Y. YYYY
    Foo: Baz
    So: don't check

    in a text field (with more text than just this). I ran a query to get the data value I'm replacing, but it seems to have spaces where the line breaks would be. Gee, thanks for erasing information...

    I want to run something like this:

    update table
       set TX_FIELD = replace( TX_FIELD
                             , 'XXXX X. XXXX   Foo: Bar  So: check',
                             , 'YYYY Y. YYYY\\r\\nFoo: Baz\\r\\nSo: don''t check'
                             )
    

    I tried that, with the value I cut and pasted from my query. And then I made an educated guess about \r\n's.

    So my question: how do I get the real, actual line break tokens so I can match the stupid text I need to replace.


  • I survived the hour long Uno hand

    @Captain
    If you're working in raw T-SQL, the special characters are CHAR(13) (for CR, which should map to \r) and CHAR(10) (for LF, which should map to \n).

    If you're working in an ORM, I'm not sure if/how your ORM will do the translation.



  • @izzion I still had to make some educated guesses about invisible whitespace, but that was a big help.



  • What's a good EML viewer for Windows? By default it wants to open in Mail, but that won't let me do anything unless I connect it with an account, which I don't want to do. I'd also prefer not to get any full email client if I can avoid it. The search results I can see range from mildly to extremely sketchy and malware-looking, so I'm hoping someone here knows a good one.


  • And then the murders began.

    @hungrier I usually use Outlook, but your objection to a full email client rules that out. 😛

    Aren't EML files plain text, so you could just use any text viewer?


  • Java Dev

    @Unperverted-Vixen said in Help Bites:

    @hungrier I usually use Outlook, but your objection to a full email client rules that out. 😛

    Aren't EML files plain text, so you could just use any text viewer?

    Sure, as long as you aren't interested in HTML content or attachments.



  • @Unperverted-Vixen I can see them in a text viewer, but it's unformatted and full of encoding artifacts like "=E2=80=99". Attachments are also right out, although for now I haven't needed them.

    Anyway I found an open source mbox viewer tool that (after some fiddling) can get the job done.



  • @Carnage, @ any other swedish speakers--

    How would you translate the string "Import from Agency Devices" (which really means "Import users from devices belonging to an agency")?

    If I type the literal string, google translate gives "Importera från byråer". If I type "Import users from agency devices", I get "Importera användare från byråenheter". Which doesn't leave me full of confidence. And we don't have "official" translations for any of our strings yet, as we're just moving into international markets. But I'd really rather not knowingly put something garbage out there (:doing_it_wrong:, I know).



  • @Benjamin-Hall said in Help Bites:

    @Carnage, @ any other swedish speakers--

    How would you translate the string "Import from Agency Devices" (which really means "Import users from devices belonging to an agency")?

    If I type the literal string, google translate gives "Importera från byråer". If I type "Import users from agency devices", I get "Importera användare från byråenheter". Which doesn't leave me full of confidence. And we don't have "official" translations for any of our strings yet, as we're just moving into international markets. But I'd really rather not knowingly put something garbage out there (:doing_it_wrong:, I know).

    I guess I should ask the same (except into French) of @remi and other french speakers.



  • "Importer depuis les appareils d'une agence" in French.

    (or "société" instead of "agence" if you mean a whole company instead of a local office)



  • @Zerosquare said in Help Bites:

    "Importer depuis les appareils d'une agence" in French.

    (or "société" instead of "agence" if you mean a whole company instead of a local office)

    Thanks. I'm not sure as to the difference between the companies/offices--our "agencies" are local fire/police/EMS organizations, usually at the city level.

    Google's translation (after I stuck a possessive in there) was "Importer à partir des appareils de l'agence". I think using the definite article there (the agency, meaning the one whose data you're looking at right now, not any other one) makes more sense, but French makes so little sense to me that it might as well be Greek.



  • @Benjamin-Hall said in Help Bites:

    "Import users from devices belonging to an agency"

    Importera användare från enhet tillhörande $1.

    Import from Agency Devices

    Importera från $1senhet

    $1 being:
    If it's regarding government agencies: myndighet
    For businesses: företag
    for any kind of organisation pretty much: organisation

    So for government:
    Importera från myndighetsenhet.
    Or:
    Importera användare fån enhet tillhörande myndighet.



  • @Benjamin-Hall said in Help Bites:

    Google's translation (after I stuck a possessive in there) was "Importer à partir des appareils de l'agence". I think using the definite article there (the agency, meaning the one whose data you're looking at right now, not any other one) makes more sense

    If that is what you mean, Google's suggestion is fine. I didn't use a definite article because I parsed "Import from Agency Devices" as "Import from from an agency's devices".



  • @Benjamin-Hall said in Help Bites:

    @Zerosquare said in Help Bites:

    "Importer depuis les appareils d'une agence" in French.

    (or "société" instead of "agence" if you mean a whole company instead of a local office)

    Thanks. I'm not sure as to the difference between the companies/offices--our "agencies" are local fire/police/EMS organizations, usually at the city level.

    I'd probably go for "organisation" (yes, that means what you think it does) in that case.

    "Agence" has a relatively specific meaning in French, which isn't the same as in English. Or rather, it has the same meaning as in English but isn't really used that way. It just... doesn't sound right. "Société" (in this usage) is for commercial activities and fire/police/etc. are not, so they wouldn't understand it in that sense. Moreover, even though I can't think of any specific example right now, I think I've already seen "organisation" used in similar situations. It seems to be the somewhat accepted/standard way to indicate an organised group of people without getting into the specifics of their status.

    Google's translation (after I stuck a possessive in there) was "Importer à partir des appareils de l'agence". I think using the definite article there (the agency, meaning the one whose data you're looking at right now, not any other one) makes more sense, but French makes so little sense to me that it might as well be Greek.

    The definite article makes sense only if the user already has somehow defined/linked the agency to the system. Say, if you have a first step such as "define agency" where a user would set whatever specifics an agency has (that seems to be the case since you're speaking of "whose data you're looking at right now"), and they can only have one such agency in your system (or there is no ambiguity at that specific point in time to which one it refers), then the definite article would be expected. If there can be several agencies (basically if the next step is going to ask users "which agency?"), or if it's the first time your app mentions agencies, use the indefinite.



  • @remi said in Help Bites:

    I'd probably go for "organisation" (yes, that means what you think it does) in that case.

    "Organisation" is fine if you mean a whole company/public organization/whatever. But if you mean a specific subgroup within it, "agence" is better. For example, the local unemployment office is usually referred to as "agence Pôle-Emploi".



  • @Zerosquare I'd disagree. There are some situations where "agence" is right to indicate a subgroup (more specifically, one physical location), but not all. In particular, I don't think any emergency service would ever call e.g. a fire station as "une agence" -- they probably also wouldn't spontaneously use "organisation" but at least they would understand it. And if the subgroup isn't all physically located in one place (e.g. all fire stations in one city), "agence" is mostly wrong.

    But I guess the only thing this discussion proves is that translations are hard and depend far too much on the context for it to make any sense to just translate a couple of words independently of everything else. So as far as @Benjamin-Hall is concerned, it's likely that any translation done this way will feel wrong, so the best he can hope for is to get it sufficiently good to be understandable (and forget all hope of getting it "right"). For that purpose, "agence" or "société" or "organisation" would work equally well (i.e. equally badly...).

    ETA: re-reading the thread, I think the point above is even stronger, as there might not be a single term that is usable for all emergency services in one given country. Maybe in the US both police and fire services would understand being referred to as "agencies" but maybe in another country each service would use a totally different word. Typically if referring to physical locations i.e. "stations" in English -- which probably isn't the target here, but that's just to illustrate -- a French police station would be a "commissariat" or "gendarmerie" (depending on which administration they depend of... and getting it wrong would be a huge faux pas!), but a fire station would be a "caserne." Calling a fire station a "commissariat" would cause complete confusion, as would calling a police station a "caserne" (unless it's a "gendarmerie" in which case "caserne" might be understood but probably not exactly in the same way and that would also cause confusion, although of a slightly different type...).


Log in to reply