Help Bites



  • Does anyone know a photo editing application with functionality close to that of PowerPoint 2010 image enhancement features? Not less and not much more.

    My relative prepares figures for a textbook by pasting them in PowerPoint, cropping/changing contrast/whatever, then saving the result as a new image. This... mostly works, but occasionally, PowerPoint manages to destroy the aspect ratio of the image. Which application would be easier to adapt to after PowerPoint? IrfanView is not the answer, apparently, or at least needs further training.


  • 🚽 Regular

    @aitap Something like Paint.Net?

    I'm used to The Gimp, but I wouldn't recommend it.
    In general, not just because it's overkill.



  • @Zecc I'm used to GIMP too, and it's definitely overkill here. We'll try Paint.NET, thanks. Although...

    "It raises the quality bar," - Jeff Atwood, Coding Horror

    Okay, we'll still try it.


  • Java Dev

    I've got a database table with numbers.
    They want to discard the 10% largest values, and return the average of the rest.

    Does anyone know a good SQL which returns that value, while iterating the table only once?



  • @PleegWat SQL doesn't provide that level of control unless you use your engine's imperative language/fragment (PL-SQL, cursors, etc)

    I'd be looking at dumping the data to a file and applying a general language to the problem.


  • Java Dev

    @Captain said in Help Bites:

    I'd be looking at dumping the data to a file and applying a general language to the problem.

    Haha no.



  • @PleegWat You're not really giving any details to help you find an answer. What SQL engine is this? How much data is it?

    The answer is basically no, though.


  • Java Dev

    @Captain Oracle. Millions of rows. And I pretty much already know the answer is going to be no.

    It's not really my problem anyway. There's politics involved. I'd be better off completely ignoring the problem until somebody told me what they want in language that makes sense, instead of us always having to guess at what they mean.



  • @PleegWat said in Help Bites:

    I'd be better off completely ignoring the problem until somebody told me what they want in language that makes sense, instead of us always having to guess at what they mean.

    I don't think any of us will live until the Heat Death of the Universe happens...


  • 🚽 Regular

    @PleegWat

    Something something window function PERCENT_RANK, never actually used ut, just heard of italso it's almost 2AM.

    So maybe something like

    WITH x as (
        SELECT
          myValue,
          PERCENT_RANK() OVER (ORDER BY myValue DESC) pr
        FROM myTable
    )
    SELECT AVG(myValue) FROM x WHERE pr > 0.1; 
    

    I should go to sleep, but maybe it points you somewhere.



  • @PleegWat If you have a value-ordered index to the data, then you could binary-search for the 10% mark, and then average the rest.

    But any other solution pretty much requires iterating twice. You have to find the cut-off value before you can average the rest.

    So... is this iterate-only-once requirement some political potato?


  • Java Dev

    @acrow said in Help Bites:

    So... is this iterate-only-once requirement some political potato?

    No, it's nastiness to do with the way we generate SQL. The top-level statement is fixed and we can only inject individual select items. I don't think those items themselves can even have subselects.

    Not wanting to break that model may be classified as me being stubborn, but anything deviating from it (or requiring two queries) would break a number of assumptions we're making throughout the product.


  • 🚽 Regular

    @Zecc said in Help Bites:

    I have the following method:

    public void UpdateThingyDimensions(int thingyId, decimal? weight, decimal? length, decimal? height, decimal? width)
    {
        var assignments = new Dictionary<string,decimal?>(4);
        if (weight != null) assignments["Weight"] = weight;
        if (length != null) assignments["Length"] = length;
        if (width  != null) assignments["Width" ] = height;
        if (height != null) assignments["Height"] = width;
        if (!assignments.Any()){
            return;
        }
        
        string sql =
            "UPDATE Thingy SET "
            + string.Join(", ", assignments.Keys.Select(colname => $"{colname} = @{colname}")
            + " WHERE ID = @thingyId ";
        
        using(SqlConnection conn = new SqlConnection(ConnectionString))
        using(SqlCommand command = new SqlCommand(sql, conn)))
        {
            conn.Open();
    
            command.Parameters.Add(new SqlParameter("@thingyId", SqlDbType.Int) { Value = thingyId });
            foreach(var kvp in assignments)
            {
                command.Parameters.Add(new SqlParameter("@"+kvp.Key, SqlDbType.Float){ Value = kvp.Value });
            }
            
            command.ExecuteNonQuery();
        }
    }
    

    This thing threw a "Connection property has not been initialized." exception on the command.ExecuteNonQuery() line.

    But it was! The connection is passed to the command in its constructor and SqlConnection.Open() is called before executing the command

    The connection string is also correct, or the program would have crashed and burned much early on, never mind that the exception would have been different.

    I'm scratching my head at this. Any ideas what could have happened here?

    PS: unfortunately I have no idea what the values of the method parameters were, other than at least one of the decimals was not null and that thingyId was valid.

    :facepalm: 😳 :headdesk: :facepalm: 😓

        using( SqlConnection conn = new SqlConnection(ConnectionString) )
        using(SqlCommand command = new SqlCommand(
            "UPDATE Product SET "
    -        + string.Join(", ", assignments.Keys.Select(k => $"{k} = @{k}")
    -        + " WHERE ID = @ProdID ", conn)))
    +        + string.Join(", ", assignments.Keys.Select(k => $"{k} = @{k}"))
    +        + " WHERE ID = @ProdID ", conn))
        {
            conn.Open();
    
    

    Which is to say I was setting CommandText to"UPDATE Product SET System.Linq.Enumerable+WhereSelectEnumerableIterator`2[System.String,System.String] WHERE ID = @ProdID , System.Data.SqlClient.SqlConnection and I wasn't passing in the connection to the command's constructor.


  • 🚽 Regular

    @Captain said in Help Bites:

    I don't know what the problem is, but I bet it's going to make you mad when you figure it out.

    I have some good news for you.


  • Java Dev

    @Zecc said in Help Bites:

    if (width  != null) assignments["Width" ] = height;
    if (height != null) assignments["Height"] = width;
    

    Did anyone mention this switcheroo yet?


  • 🚽 Regular

    @PleegWat O_O

    ...

    Thanks.



  • Short question: My parents just got a split air conditioner and now they've got problems using their DECT-based wireless phones (DECT: 1880 - 1900 MHz). Is it possible for the unit to interfere with this signal and what would be the best way to prove it (aside from turning it off and on again).



  • @Rhywden said in Help Bites:

    Is it possible for the unit to interfere with this signal

    It's got an electric motor, and likely a PSU of some sort, so yes.

    and what would be the best way to prove it (aside from turning it off and on again).

    A spectrum analyzer.

    E.g.:



  • @acrow thanks. will have a look if someone has such a gadget lying around (or, if it's not too expensive, might just buy one for school - I can think of several applications where I might use it).



  • Look up RTL-SDR receivers. They cost next-to-nothing, they should be enough for basic checking, and have plenty of interesting other uses. Just make sure that the one you're buying covers the frequency range you're interested in (beware: some have gaps between the lowest and highest frequency).


  • Considered Harmful

    This post is deleted!


  • Request: Is there some way of magically populating local (within a local network) dns names without manually modifying the hosts files on all the clients?

    I have a linux (Debian) fileserver. It has a system name (shamesh). I'd like to be able to, say, SSH into it by doing ssh <user>@shamesh, but that doesn't seem to have propagated outside the box. Is there some magic incantation I need to run?

    Similarly, it's running SAMBA for serving files. I'd like to be able to mount that by referencing the name, but that doesn't show up on either the Windows (11) client or the macOS client as a valid share; connecting via ip works however.


  • Notification Spam Recipient

    @Benjamin-Hall
    Typically that might be handled by your router, or your DHCP server sending up registrations to the DNS server (if you're complicated and not using an all-in-one device like most people).

    It depends on what you have that's doing the name resolving, really. On mine, everything is coming from the same box so DHCP registrations get added to the local DNS on the router and all is dandy, but you might need to tick a box or something.



  • @Tsaukpaetra My router is correctly getting the host names of all devices. The other devices on the network are not getting any of them.


  • Discourse touched me in a no-no place

    @Benjamin-Hall said in Help Bites:

    The other devices on the network are not getting any of them.

    Check those devices are configured to get the DNS from the router



  • @loopback0 said in Help Bites:

    @Benjamin-Hall said in Help Bites:

    The other devices on the network are not getting any of them.

    Check those devices are configured to get the DNS from the router

    That did the trick. They were using only google's DNS servers. Which, of course, knew absolutely nothing about my local network.



  • @Benjamin-Hall "Other devices" have what for the DNS server? On my home network, the router handles dhcp and dns, so sends its own ip for the DNS in the DHCP offer. This means my PC is sergyar and my printer is ml2851 and can be found by these names by anything else, because they are told the DNS is the router.

    Edit :hanzo:



  • Another short question: I'm reading and writing data from a MongoDB using C# and found myself repeating basically the same code for every model I was plonking in there.

    So I wanted to generalize that code a bit. My first attempt was to use an interface and then go from there like this:

    public interface IMongoEntry
    {
        public Guid Id { get; init; }
    }
    
    //And then later do this
    private IMongoCollection<IMongoEntry> GetCollection(IMongoEntry entry) => _client.GetDatabase(_database).GetCollection<IMongoEntry>(entry.GetType().Name);
            
    public async Task<ImmutableList<IMongoEntry>> GetAll(IMongoEntry empty)
    {
         var collection = GetCollection(empty);
         var filter = Builders<IMongoEntry>.Filter.Empty;
         var list = await (await collection.FindAsync(filter)).ToListAsync();
         return ImmutableList<IMongoEntry>.Empty.AddRange(list);
    }
    

    which obviously is non-ideal. Firstly there's the need for the parameter in the GetAll and GetCollection methods, secondly, while I can do GetAll(new ClassImplementingTheInterface()) it will then return a List<IMongoEntry> instead of List<TheClassIWant>.

    Finding the right keywords is not easy and I'd just need a pointer on what to do different (or if an Interface is even the right idea in the first place).



  • @Rhywden Okay, as always, when asking a question I promptly find an answer.

    Basically, I converted the methods to this:

    private IMongoCollection<T> GetColl<T>() where T : IMongoEntry =>
                _client.GetDatabase(_database).GetCollection<T>(typeof(T).Name);
    
    public async Task<ImmutableList<T>> GetAll<T>() where T : IMongoEntry
            {
                var collection = GetColl<T>();
                var filter = Builders<T>.Filter.Empty;
                var list = await (await collection.FindAsync(filter)).ToListAsync();
                return ImmutableList<T>.Empty.AddRange(list);
            }
    

    Seems to work. Though I'm open for suggestions.


  • Considered Harmful

    @Rhywden said in Help Bites:

    I'm open for suggestions.

    val


  • And then the murders began.

    @Rhywden said in Help Bites:

    Seems to work. Though I'm open for suggestions.

    The method should be called GetAllAsync so devs calling it have that extra reminder that they need to await the result. Other than that, seems fine to me.


  • Notification Spam Recipient

    Status: Anyone know how to tell Windows to never encrypt a particular drive with bitlocker?

    I keep finding my Windows To Go drive encrypting itself and it's fucking annoying.

    Note: I don't mean disable the Bitlocker service, or disable it once on the drive by telling Bitlocker to be "Off", because this drive is used in arbitrary machines and obviously I can't go and disable the service on every machine I plug it into.

    It just likes to start encrypting itself and I don't really know why....


  • BINNED

    Can I setup Windows 10 to either disallow downloading any executable files at all (for one user account), or alternatively block opening any executables with a “downloaded” zone identifier?

    Right now it seems to allow executing such files and only pops up a warning that the file is from the internet yadda yadda and might harm your computer, which is apparently not big and scary enough for my mom to not click through anyway.

    Apparently my google-fu is too weak to find any information on this, everything I find for “windows 10 block downloaded executables” is people asking how to stop blocking (and the articles are all unusable bullshit). Adding -stop to the search at least bring me to one outdated question on stack exchange that’s closed off-topic. :rolleyes:
    And manually searching through the Windows 10 settings menus… god is this OS a fucking mess. It does try to trick me into installing OneDrive for :airquotes: security :airquotes: reasons though.


  • Discourse touched me in a no-no place

    @topspin Windows has the "Software Restriction Policies" which can be configured in the Group Policy editor and allows blocking of MSI files by zone, but think for EXEs you'd need to block by path.

    If she's got W10 Home then it doesn't have the Group Policy editor by default but there are ways to add it back, and the rules can probably be configured using the registry.


  • BINNED

    @loopback0 yeah, it’s Home I think. Blocking by path probably wouldn’t help.



  • And worse yet: some Group Policies are only available within a domain, and you cannot set them on an individual machine, except when you do so from the domain controller. :wtf_owl:



    1. I have a laptop whose only provision for external power is a USB-C port.
    2. I have a power supply that outputs to a USB-C plug.
    3. I have a docking station that works with the laptop, except that it doesn't supply power out the USB-C plug.

    I need to somehow connect 2 and 3 to 1 at the same time, but 1 has only a single USB-C port. Is there some sort of adapter that will allow connecting both 2 and 3 to a single port, one for power and the other for data? My GoogleDDG-fu is failing me this morning.


  • Notification Spam Recipient

    @HardwareGeek said in Help Bites:

    except that it doesn't supply power out the USB-C plug.

    What a shit duck, sorry.

    I guess you'll just have to go through a dongle like this:


  • And then the murders began.

    @HardwareGeek said in Help Bites:

    I need to somehow connect 2 and 3 to 1 at the same time, but 1 has only a single USB-C port. Is there some sort of adapter that will allow connecting both 2 and 3 to a single port, one for power and the other for data? My GoogleDDG-fu is failing me this morning.

    Assuming you have the following:

    • A non-USB-C power supply for the docking station
    • A USB-A port on the laptop

    Can you use the USB-C port on the laptop for power and then use a USB-C -> USB-A converter for the docking station?



  • Thanks for the suggestions, but it turns out it isn't necessary. There's a second USB-C port on the laptop that I overlooked. It's not obvious that its USB-C, because it's munged together on the same physical connector with some other port, so the oval shape isn't obvious unless you look closely.

    b2fb28db-c99f-41f5-948d-16f5f4ce98da-image.png

    So now I have one docking station for the power and the other for the monitors. (I neglected to mention that reason I want to use the other docking station is that the Lenovo one (that supplies power) can't handle two 4k monitors. It'll handle one, but it will only do 1080 on the second. My 3rd-party dock will drive both monitors at 4k, but won't power the laptop.)



  • @HardwareGeek In grand irony, that "munged" connector is probably meant for a specific subset of Lenovo's docking stations.

    The other connector is Ethernet, from the markings. Which kind of fits the bill.



  • @HardwareGeek said in Help Bites:

    Thanks for the suggestions, but it turns out it isn't necessary. There's a second USB-C port on the laptop that I overlooked. It's not obvious that its USB-C, because it's munged together on the same physical connector with some other port, so the oval shape isn't obvious unless you look closely.

    b2fb28db-c99f-41f5-948d-16f5f4ce98da-image.png

    Oh! I didn't realize that was USB-C either. (Never really looked closely at it)

    @acrow said in Help Bites:

    The other connector is Ethernet, from the markings.

    It is. You need a special Lenovo adapter, of course.



  • @dcon said in Help Bites:

    special Lenovo adapter,

    Ah, I was wondering what sort of connector, since I've never seen one like that before. Figures it'd be proprietary.



  • @HardwareGeek said in Help Bites:

    @dcon said in Help Bites:

    special Lenovo adapter,

    Ah, I was wondering what sort of connector, since I've never seen one like that before. Figures it'd be proprietary.

    20220818_124436.jpg



  • @remi said in Help Bites:

    Do you have recommendations for a scientific calculator app that doesn't totally suck?

    I am quite happy with qalculate. It can do dimensional calculations ((2 km + 350yd) / 11 min to mph), which I haven't seen basically anywhere else. Plus it can even download exchange rates, so expression like 25.3 m * 2.15 USD/ft to EUR work too.

    The only downside is that as far as I can tell there is no mobile version.

    @remi said in Help Bites:

    e.g. switching from deg to rad requires going into the settings each time

    I rarely need trigonometry, but IIRC dimensional calculations apply to angles as well, so you can set the mode, but you can still mix degrees and radians in the same expression by suffixing them with appropriate ‘units’.

    @remi said in Help Bites:

    Other things that I noticed is that I have to type the full function names (e.g. sin) rather than having a dedicated key

    Qualculate does have some dedicated keys, but since it accepts all input from the physical keyboard, I find that faster to just type and leave that space for history. Or more convenient, because I can type without looking at the keyboard, instead looking at whatever source material I am working with, but I can't do that for clicking on buttons.



  • @Bulb You're a bit late to the party (as if you weren't aware of that...), but thanks anyway.

    Dimensional calculations sounds very nice but it isn't really what I need most of the time. I'm dealing with mostly strongly typed data where the unit is usually handled outside of the kind of small calculations I need to do by hand, and quite often it's SI.

    Also, since my original post I've been using HiPER and I'm reasonably satisfied with it. I can find my way around to the functions I need, and it Just Works ™ which is my main requirement.

    Though it's a mobile app, meaning I still don't have a proper calculator on my computer itself, and for this reason I will try your suggestion. So thanks again!



  • Question: So, since I apparently solved my connectivity issues, here's what I'm currently mulling about: The cable from the point-of-entry in the cellar to my appartment drops the signal-to-noise-ratio (SNR) from 19 dB to 9 dB. VDSL uses QAM.

    So, is there a way to calculate how much loss in SNR should be expected of, say, 10 meters of twisted-pair cable?


  • I survived the hour long Uno hand

    @Rhywden
    It looks like most cable loss calculators I can find are for coax cable. That said, I would expect that most twisted-pair cable should be more or less pass/fail by distance -- I know the magic number in Ethernet land is 100m, and it looks like the magic number in VDSL2 land is around 1200m https://www.versatek.com/most-frequently-asked-vdsl2-questions/#:~:text=What is the farthest distance,yielding speeds comparable to ADSL2%2B.

    Assuming your building is only tens of meters tall, I would not expect you to lose 90% of the signal (10 dB) from a wire running that distance.



  • @izzion Okay, thanks, that makes sense. Distance to the VDSL hub is about 350 meters, so, yes, a 10 dB loss over the last 10 meters is a bit extreme.


  • Java Dev

    @izzion I recall in ADSL and ADSL2 there was a pretty direct mostly linear relation between distance, SNR, and maximum attainable speed. As well as that the speed fell off much faster for non-twisted cable even if there are no neighbouring cables to crosstalk with.


Log in to reply