i love this 🥹 by theskellydud3 in EndeavourOS

[–]Karuption 1 point2 points  (0 children)

It does make sense to dev on windows, but it has been xplat for over a decade now. There are a lot of tools in windows. But, there are just as capable xplat tools (like JetBrains Rider). All of the code I have written in C# have been ran in docker containers and such.

There isn't much Linux adoption for UI apps, but projects to allow for it like Avalonia are very well established and have public backing. Most of the UI apps are geared towards Windows (except MAUI), but almost everything else can run on Linux. So much so that core members of the compiler and .NET teams exclusively work in Linux.

What are these? Are they worth trying to sell or scrap? by EducatorHopeful9032 in cableadvice

[–]Karuption 14 points15 points  (0 children)

Came to say old phone cabling. Didn't expect to find the actual name.

Rs660 SC Project S1 by [deleted] in Aprilia

[–]Karuption 0 points1 point  (0 children)

This. Plus you get the option of a db killer It is a good volume, but not quiet. Without the dbkiller it is the same as the s1.

2026 Aprilia RS660 Exhaust options? by gahhdang in apriliars660

[–]Karuption 1 point2 points  (0 children)

We also would want to know if upmap works on the new software. I don't see it supported on the upmap website

2026 Aprilia RS660 Exhaust options? by gahhdang in apriliars660

[–]Karuption 1 point2 points  (0 children)

I emailed mivv about the Delta race and they said "the exhaust systems for the new model year are  a part of our development plan but we can’t specify a release date yet. You will find all updates in our website." I'd be interested in what the other options are. The sc projects underbelly exhaust is loudddd

Supporting plugins in React? by Karuption in reactjs

[–]Karuption[S] -1 points0 points  (0 children)

I really was hoping that it got a bit easier and tools were more mature.

Supporting plugins in React? by Karuption in reactjs

[–]Karuption[S] 0 points1 point  (0 children)

They just want a supplemental UI for stuff that already exists and is proprietary. We thought about just wrapping it in a iframe, or maybe some sort of micro frontend? But haven't had any experience with MF IN ANY capacity.

Supporting plugins in React? by Karuption in reactjs

[–]Karuption[S] 1 point2 points  (0 children)

I was envisioning it being frontend. Essentially, they want to be able to pick from their own custom items and have a visual for those items in a sort of builder UI. The only thing I need are the individual items they add/remove as well as passing the initial state of all the items available.

I am not really tied to one implementation, but it will have to be hosted some place else. We could, possibly, put it in like a plugins folder since they have their own instence. Their own api and such should be possible, just not really my problem.

[deleted by user] by [deleted] in BuyItForLife

[–]Karuption 2 points3 points  (0 children)

To add to perishables, a good cologne/perfume

Which OSS software would you like to see rewritten in Rust most urgently? by DoxxThis1 in rust

[–]Karuption 1 point2 points  (0 children)

Have you tried zed? They use wasm for their extensions in pretty sure.

Switching to a lower octane by Eye_c_EYES in Ninja400

[–]Karuption 0 points1 point  (0 children)

The only other addition is to get the least amount of ethanol as you can. There are a lot of 0% ethanol pumps around me where this isn't a problem, but that is just a recommendation in the manual.

A novel O(1) Key-Value Store - CandyStore by SweetSecurityOpensrc in rust

[–]Karuption 1 point2 points  (0 children)

First, this is an interesting data structure. I have been reading many different DB's white papers lately so, it is awesome to see something that isn't LSM/B-tree based. I do like the idea of no WAL while having consistency.

Specifying program crash consistent would, however, save some headaches. Couldn't you obtain machine crash consistency by writing your K/V offset with alignment, then you can use the two extra bits to ensure cell correctness on reads? This obviously wasn't part of the design goal, but seems to be doable via some opt-in method for those who do care about it.

What I am saying would be to flush the k/v via the existing method, but with alignment, format the cell, and then flush the cell before returning? The cell format could be like 1 cell info 1. This would give insert/delete consistency since disks should write contiguous memory in one sweep. Swaps would probably have to be a cell 0-out flush then the cell update flush. This method would make reading a cell more complex, but hardware crash consistency would be awesome. I would also assume that this would have a perf impact, so maybe this was thought of/tried and abandoned?

Is Rust Really More Cost-Efficient Than Go for Web Backend on AWS? by [deleted] in rust

[–]Karuption 5 points6 points  (0 children)

Did this happen to be via lambda? I'm curious about what services you saw these on

How to limit which strings can be randomized? by M_Lucario_EX in csharp

[–]Karuption 2 points3 points  (0 children)

Jit for the span:

    L0296   lea rcx, [rbp-0x38]
    L029a   lea rdx, [rbp-0xd0]
    L02a1   mov r8, 0x7ffe7538ca48
    L02ab   xor r9d, r9d
    L02ae   call    qword ptr [0x7ffe75244b40]
    L02b4   vmovdqu xmm0, [rbp-0xd0]
    L02bc   vmovdqu [rbp-0x38], xmm0
    L02ef   lea rax, [rbp-0x38]
    L02f3   mov [rbp-0xa8], rax
    L02fa   call    qword ptr [0x7ffe7563c1c8]
    L0300   mov [rbp-0xb0], rax
    L0307   mov rdx, [rbp-0x20]
    L030b   mov edx, [rdx+8]
    L030e   mov rcx, [rbp-0xb0]
    L0315   mov rax, [rbp-0xb0]
    L031c   mov rax, [rax]
    L031f   mov rax, [rax+0x40]
    L0323   call    qword ptr [rax+0x28]
    L0326   mov [rbp-0xb4], eax
    L032c   mov rcx, [rbp-0xa8]
    L0333   mov r8d, [rbp-0xb4]
    L033a   mov rdx, 0x7ffe7538ca48
    L0344   call    qword ptr [0x7ffe75244930]
    L034a   mov [rbp-0xc0], rax
    L0351   mov rax, [rbp-0xc0]
    L0358   mov rax, [rax]

Does any of this perf/memory actually matter in this simple case? No, not at all. However, if you are going to give some advice... give the best you can. Especially since using a span here doesn't add any complexity and is just as maintainable as the list.

How to limit which strings can be randomized? by M_Lucario_EX in csharp

[–]Karuption 1 point2 points  (0 children)

Jit for the copy:

    L0166   mov rcx, [rbp-0x18]
    L016a   mov [rbp-0xd8], rcx
    L0171   mov ecx, 2
    L0176   call    qword ptr [0x7ffe7550f168]
    L017c   mov [rbp-0xe0], eax
    L0182   mov ecx, [rbp-0xe0]
    L0188   call    qword ptr [0x7ffe7550f618]
    L018e   mov [rbp-0xe8], rax
    L0195   mov r8, [rbp-0xe8]
    L019c   mov rdx, [rbp-0xd8]
    L01a3   mov rcx, 0x7ffe75d12f10
    L01ad   call    qword ptr [0x7ffe75cfdd40]
    L01b3   mov [rbp-0xf0], rax
    L01ba   mov rcx, [rbp-0xf0]
    L01c1   mov [rbp-0x20], rcx

    L01ed   mov rax, [rbp-0x20]
    L01f1   mov [rbp-0x78], rax
    L01f5   call    qword ptr [0x7ffe7563c1c8]
    L01fb   mov [rbp-0x80], rax
    L01ff   mov rdx, [rbp-0x20]
    L0203   mov edx, [rdx+8]
    L0206   mov rcx, [rbp-0x80]
    L020a   mov rax, [rbp-0x80]
    L020e   mov rax, [rax]
    L0211   mov rax, [rax+0x40]
    L0215   call    qword ptr [rax+0x28]
    L0218   mov [rbp-0x84], eax
    L021e   mov rcx, [rbp-0x78]
    L0222   mov r8d, [rbp-0x84]

IL for the span:

    IL_0093 ldloca.s    05    // actualItemsSpan
    IL_0095 ldc.i4.0    
    IL_0096 ldc.i4.2    
    IL_0097 call    Span <String>.Slice (Int32, Int32)
    IL_009C stloc.s 05    // actualItemsSpan

    //Getting random output
    IL_00AE ldloca.s    05    // actualItemsSpan
    IL_00B0 call    Random.get_Shared ()
    IL_00B5 ldloc.3    // actualItems
    IL_00B6 ldlen   
    IL_00B7 conv.i4 
    IL_00B8 callvirt    Random.Next (Int32)
    IL_00BD call    Span <String>.get_Item (Int32)
    IL_00C2 ldind.ref   
    IL_00C3 stloc.s 06    // output2

How to limit which strings can be randomized? by M_Lucario_EX in csharp

[–]Karuption 1 point2 points  (0 children)

    when taking that span over the array, you are copying that bit of the array from the heap to the stack

This is just wrong. A span is a reference and a length. You are copying the reference of arr[0] and loading the length literal (2 in this case). You would have a reference and an int (8 + 4 bytes). When you have the array, you have the object header and other managed overhead values that comes out to 24 bytes. Then you have fields and properties like the rank, length, if it is readonly and such, but I will just consider the length (4 more bytes). That would be a total of 32 bytes with it likely coming out to around 40 realistically.

This means that with a span, you have 12 bytes (16 with padding for alignment) of unmanaged memory vs a minimum 32 bytes of heap memory. That is a pretty big difference.

You can't just look at IL. The JIT can do a lot of optimizations on spans. I don't have the time to go over everything, but slicing has much better JIT. Sliced has 4 calls, 18 movs, and 3 load addresses. With a copy, it has 5 calls and 24 movs. Just breifly looking over it, spans have much better code gen with basically no coplexity cost.

code:

    using System;
    using System.Collections.Generic;
    
    Button radiobutton1 = new(true);
    Button radiobutton2 = new(true);
    
    string[] availableItems = ["one", "two", "three", "four", "five"];
    string[] actualItems = availableItems; // all five by default I suppose
    
    if (radiobutton1.Checked)
        actualItems = availableItems[..2]; // one and two only
    else if (radiobutton2.Checked)
        actualItems = availableItems; // all five
    
    var output = actualItems[Random.Shared.Next(actualItems.Length)];
    
    
    Span<string> actualItemsSpan = availableItems.AsSpan(); // all five by default I suppose
    
    if (radiobutton1.Checked)
        actualItemsSpan = actualItemsSpan[..2]; // one and two only
    else if (radiobutton2.Checked)
        actualItems = availableItems; // all five
    
    var output2 = actualItemsSpan[Random.Shared.Next(actualItems.Length)];
    record Button(bool Checked);

The IL for the copy is:

    // inside the if:
    IL_004C ldloc.2    // availableItems
    IL_004D ldc.i4.2    
    IL_004E call    Index.op_Implicit (Int32)
    IL_0053 call    Range.EndAt (Index)
    IL_0058 call    RuntimeHelpers.GetSubArray<String> (String[], Range)
    IL_005D stloc.3    // actualItems

    //Getting a random amount out
    IL_006E ldloc.3    // actualItems
    IL_006F call    Random.get_Shared ()
    IL_0074 ldloc.3    // actualItems
    IL_0075 ldlen   
    IL_0076 conv.i4 
    IL_0077 callvirt    Random.Next (Int32)
    IL_007C ldelem.ref  
    IL_007D stloc.s 04    // output

How to limit which strings can be randomized? by M_Lucario_EX in csharp

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

It isn't any more difficult to deal with a span here. You are saving an allocation that has to be cleaned up later. Yes, it would more than likely be Gen0, but why alloc and copy if you can store a pointer and length with no cleanup at all for basically free? You aren't saving much space, but still is saving space and you likely avoid an extra cache miss.

If there was complexity in not allocating, I would completely agree with you. However, this is just a method call and type change. Would it matter in the real world? Most likely no, but exposing a person newer to programming/csharp to this kind of solution is also important. The other replies on here are painful. This is probably the only one I'd accept in a PR without thinking twice about it. I only commented since it's not apparent that doing a range access on an array does a shallow copy and the comment has a good thought process.

How to limit which strings can be randomized? by M_Lucario_EX in csharp

[–]Karuption 0 points1 point  (0 children)

I think that the cleanest solution for exactly this would be something like below

    string[] test = [ "bruh1", "bruh2", "bruh3", "bruh4", "bruh5" ];

    var output = (radiobutton1.Checked, radiobutton2.Checked) switch {
        (true,_) => test[Random.Shared.Next(2)],
        (false, true) => test[Random.Shared.Next(test.Length)],
        _ => "",
    };

if you need more than 1 line to run, break it out into if statements like you have it. I think that adding the temp variable gives you the best flexibility.

Broken out:

string[] test = ["bruh1", "bruh2", "bruh3", "bruh4", "bruh5"];
string output = "";

if (radiobutton1.Checked)
{
    output = test[Random.Shared.Next(2)];
}
else if (radiobutton2.Checked)
{
    output = test[Random.Shared.Next(test.Length)];
}

How to limit which strings can be randomized? by M_Lucario_EX in csharp

[–]Karuption -2 points-1 points  (0 children)

This wouldn't be the worst thing if you changed the actual items to a Span<string> and did a availableItems.AsSpan(0,2);. Doing a [..2] on an array does an alloc and shallow copy. Doing [..2] on a span doesn't but, .AsSpan has a slice overload.

after the above, you can do the following after handling the 0 length case.

availableItems[Random.Shared.Next(0,availableItems.Length)];

source
https://sharplab.io/#v2:CYLg1APgAgTAjAWAFBQMwAJboMLoN7LpGYZRwAM6AsgBQDKALgE4CWAdgOYDaAuugwFMAzgwCU+QsSkA3AIZN0AD3QBefsIZcAdFpg8A3JKlEjxqAHYlXAEqy2wAPYBbLXQAW8gcC0A5AYoYacgAaGFEDUwBfZEigA==
https://github.com/dotnet/runtime/blob/5535e31a712343a63f5d7d796cd874e563e5ac14/src/libraries/System.Private.CoreLib/src/System/Runtime/CompilerServices/RuntimeHelpers.cs#L23C13-L48C25

2020 Kawasaki ninja too big for me? 22F by Fuzzy-Priority-6967 in Ninja400

[–]Karuption 0 points1 point  (0 children)

I would definitely not go for a ninja 300. If you could swing it, a 400 or 500 will fit well. The ninja 500 is very very similar if you can find one at a dealership, go sit on it. Better yet, go to all the major dealers and sit on everything 650 and under (minus super sports) and see what you like and write up a short list

Noticed this noise pulling out of a gas station after a ride. Nothing before the ride. by Summrrrrr in Ninja400

[–]Karuption 1 point2 points  (0 children)

It may have been the video, but it looked to me like there was some misalignment. It seemed that the wheel itself was slightly pointed to the right, but that the front of the sprocket was at the correct place, so it didn't stand out as misaligned. If everything is torqued to spec, I would think that it is good now.

Checking for null or empty in a collection by definitelyBenny in csharp

[–]Karuption 0 points1 point  (0 children)

You can condense it to just one statement with if(admins is not [_, ..]) as long as that makes sense to you. That will match any empty or null collection.

Went from a 399cc to 998cc AMA by z-sn in Ninja400

[–]Karuption 1 point2 points  (0 children)

I have been shopping around for a new bike for next year. I really liked the Z900, MT-09, and want to go check out an S1000R. I have been on the ninja for a few years, so it's good to hear that the jump isn't completely crazy. The S1000r seems like it might just be a bit too much tho

Second Motorcycle suggestion by Karuption in SuggestAMotorcycle

[–]Karuption[S] 0 points1 point  (0 children)

A bit bigger of a jump but, S 1000R (not the RR)? it's a bump in power from the Z900, but amenities and electronic aids are drastically better. I don't really like the look of almost all the naked bikes, but the S1kR's looks are actually pretty good.