tuna

joined 6 months ago
[–] tuna@discuss.tchncs.de 1 points 4 months ago

You might be okay with this:

macro_rules! span {
    ($line:expr, $column:expr) => {
        Span {
            line: $line,
            column: $column,
            file_path: None,
        }
    };
    ($line:expr, $column:expr, $file_path:literal) => {
        Span {
            line: $line,
            column: $column,
            file_path: Some($file_path.to_string()),
        }
    };
    ($line:expr, $column:expr, $file_path:expr) => {
        Span {
            line: $line,
            column: $column,
            file_path: $file_path,
        }
    };
}

Playground

However, sometimes I don't want to pass in the file path directly but through a variable that is Option.

Essentially I took this to mean str literals will be auto wrapped in Some, but anything else is expected to be Option

[–] tuna@discuss.tchncs.de 1 points 4 months ago

Another optimization:

  • The first index of each index array can be filled by a function. For 257x257 that would remove 8,487,169 checks out of... 2,164,392,321. Not much, but it's basically a free optimization, so might as well!
[–] tuna@discuss.tchncs.de 2 points 4 months ago (1 children)

More progress on the Finite Projective Plane (incidence matrix) generation from last week. There already exists an algorithm to generate boards of order p+1 where p is prime. It is stateless, so with CUDA we can generate huge boards in seconds since all you need is the x, y position and board size. 258x258 under 3s!

However, p+1 isn't the only sequence. It seems by our observations that the fermat numbers also generate valid boards, using our "naïve" algorithm.

Unfortunately 3x3, 5x5, and 17x17 might not contain all the nuggets of generality to find a nice algorithm like the p+1, so we're gonna generate the next up: 257x257. We've been improving the naïve algorithm since it is too slow. (The resulting image would be 65793x65793)

  • Rather than allocating the 2d boolean grid, we represent where the true elements would be using row and column indexes. This is okay because of the constraint which limits how many true elements can be in a row/column
    • benefit 1 — less memory usage: "O(2n)" vs O(n²) ((for 257x257: 129MiB vs 4GiB))
    • benefit 2 — faster column-major lookups (flamegraph spent a lot of time sitting in iterators)
    • overall speedup: about 2.7x
  • Speed up index lookup with binary search
    • The index list is sorted by nature. To exhaustively check a dot is valid, it checks n² spots in 2 lists of size n. Slightly more expensive than the grid given the 2 index lists. Rather than slice::contains, use slice::binary_search(...).is_ok()
    • overall speedup: about 2.1x

Next steps:

  • Assume a square grid and exploit its diagonal symmetry to treat row lookups as column lookups
  • Use multi threading to gain a partial speedup
    • Essentially if row 1 is 50% completed, row 2 can be up to 50% completed.
    • I think you get different speeds depending whether the threads and symmetry folds are both row/column major or one is row-major and the other is column-major. My gut says both need to be aligned because there's less waiting involved.
[–] tuna@discuss.tchncs.de 2 points 4 months ago* (last edited 4 months ago)

Apparently generating "Finite Projective Planes". For context on how I got here, I went camping with my family and brought the game Spot It. My brother was analyzing it and came up with the same type of pattern.

When we got home he made a python script to generate these boards, but it was quite slow, so he half joked asking me to rewrite it in Rust.

I kinda struggled a bit since I didn't fully understand what it was doing. Near the end I even got a segfault using safe code😃! (i was spawning a thread with a large stack size, and allocating huge slices on its stack, rather than you know.. boxing the slice Lol.) When I finally got it working, it ended up being in the ballpark of a 23x speedup. Not bad for changing the language choice!

There's lots of room for improvement left for sure. The algorithm could benefit with some running statistics about cols/rows and the algorithm itself is quite naïve and could maybe be improved too :P

[–] tuna@discuss.tchncs.de 37 points 4 months ago

Imagine they have an internal tool to check if the hash exists in their database, something like

"SELECT user FROM downloads WHERE hash = '" + hash + "';"

You set the pdf hash to be 1'; DROP TABLE books;-- they scan it, and it effectively deletes their entire business lmfaoo.

Another idea might be to duplicate the PDF many times and insert bogus metadata for each. Then submit requests saying that you found an illegal distribution of the PDF. If their process isn't automated it would waste a lot of time on their part to find the culprit Lol

I think it's more interesting to think of how to weaponize their own hash rather than deleting it

[–] tuna@discuss.tchncs.de 2 points 5 months ago

/dev/sdX is a file, and both dd, cat can read files in full. You can even try something like zstd to compress it too.

One of the nice things about dd though is you can see the progress with --status=progress

[–] tuna@discuss.tchncs.de 3 points 5 months ago

I think it is so that the subvolume can be mounted with different options. You can of course have a mixed layout which might be more convenient, so that say root and home subvolumes mount with the same options, but swap mounts with different options. And the top level never gets mounted at all.

toplevel (not mounted)
+-- @ (subvolume mounted on /)
    +-- home (subvolume, looks like a folder, same mount options as @)
    +-- usr (folder, gets snapshotted by @)
    +-- ...
+-- @swap (subvolume with different options, mounted on /swap)

I set mine up with a purely flat layout so I haven't verified this is true, but it sounds reasonable.

Here's the documentation I was looking at:

https://web.archive.org/web/20220103010302/https://btrfs.wiki.kernel.org/index.php/SysadminGuide#Flat

[–] tuna@discuss.tchncs.de 2 points 5 months ago (1 children)

Screenshot woulda been better just so everyone sees the same thing lol. I wasn't sure what it would look like because on browser it highlighted some things green, and on Voyager it seems to highlight 4+ space indented as gray. No clue what is going on there :D

vim with :set virtualedit=all gets pretty close being able to "paint" text anywhere... unfortunately i was on my phone and didn't think to use it

[–] tuna@discuss.tchncs.de 13 points 5 months ago* (last edited 5 months ago) (4 children)
o Windows 10
|
o Linux Mint
|
|\__
|   \
|    o Manjaro KDE
|    |
o Fedora KDE
|    |\__
|    |   \
x    |    o Windows 11
     |    o Windows 11 + Arch Linux
     |    |
     o Arch Linux
     |    |
     |    |
     |    o Windows 11 + Debian KDE
     |    |

hopefully it renders well on your client :D

[–] tuna@discuss.tchncs.de 10 points 5 months ago (1 children)

My first impression is that it feels fake because of:

when kids our on him

our -> are

Come try are boy

are -> our

Maybe it depends on accent but "are" and "our" are homophones in my accent and if you spelled by sound you'd likely spell "our" as "are" ..i cant help but feel like it's intentionally increasing the mistake counter :(

[–] tuna@discuss.tchncs.de 16 points 6 months ago (1 children)

XWayland normally runs x11 apps seamlessly (more or less) in Wayland

XWayland rootful spawns a window which is like a virtual monitor running a full x11 session inside it. You spawn apps inside of the window using the DISPLAY variable

view more: ‹ prev next ›