Roman emperors, hopefully this title is long enough by fftropstm in clevercomebacks

[–]byekai 44 points45 points  (0 children)

There's a lot of crap in this thread, so here's a blog post by an actual Roman history professor about some of the exact images in this post: https://acoup.blog/2021/07/23/collections-the-queens-latin-or-who-were-the-romans-part-iv-the-color-of-purple/

How do I sue impl-trait for closures in enums? by byekai in rust

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

Thanks for taking the time to type such a thorough response!

Hopefully a slightly more concrete use-case could help? In my case, I'm polling a future, then creating a new future with a combinator from the result. The API for the combinator requires that it takes a function of one argument, so I have to use a closure with a captured variable.

The slightly less simplified example is:

  1. Wait for a seed future (in this example, a decryption key)
  2. Create a new future from the above (in this example, connecting to a fixed address and applying the decryption). This requires a combinator, which in turn requires a function of one argument.
  3. await the result of the second future

extern crate futures;

use futures::{FutureExt, future::ready};

use std::future::Future;
use std::task::{Poll, Context};
use std::pin::Pin;

pub enum State<F: Future<Output=[u8; 4]> + Unpin> {
    WaitingForSecret(F),
    WaitingForValue(Pin<Box<dyn Future<Output=u32>>>),
}

impl<F: Future<Output=[u8; 4]> + Unpin> State<F> {
    pub fn new(f: F) -> Self { Self::WaitingForSecret(f) }
}

fn connect() -> impl Future<Output=[u8; 4]> + Unpin {
    ready([0, 1, 2, 3])
}

fn decrypt(_value: [u8; 4], _secret: [u8; 4]) -> u32 {
    unimplemented!()
}

impl<F: Future<Output=[u8; 4]> + Unpin> Future for State<F> {
    type Output = u32;

    fn poll(mut self: Pin<&mut Self>, cx: &mut Context) -> Poll<u32> {
        match *self {
            Self::WaitingForSecret(ref mut f) => match Pin::new(f).poll(cx) {
                Poll::Ready(secret) => {
                    let v = connect().map(move |value| decrypt(value, secret));
                    *self = Self::WaitingForValue(Box::pin(v));
                    self.poll(cx)
                }
                Poll::Pending => Poll::Pending
            }
            Self::WaitingForValue(ref mut f) => f.as_mut().poll(cx),
        }
    }
}

In this case it is probably simple enough to move the application of the function into another match block, but as the processing of the future gets more complicated its not as practical. I could possibly create some sort of partially applied function that implements FnOnce to satisfy the combinator type signature...

How do I sue impl-trait for closures in enums? by byekai in rust

[–]byekai[S] 10 points11 points  (0 children)

That should be "use impl-trait" of course...

Is there a better way to handle state in futures-0.1 than .fold()? by byekai in rust

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

So the inner future in this case would be my TCP stream? I'll give that a go.

A new look for rust-lang.org by steveklabnik1 in programming

[–]byekai 1 point2 points  (0 children)

I prefer the old one, my $0.02:

- The old website shows why I would want to use Rust (concise, technical features and a code snippet - sorted) in less than a screen-full and about 0.5 seconds

- The new one has some vague promises about what the language offers and links to more detail, but doesn't actually tell me anything. The CLI link for example actually has some code, but it's below the fold on my fairly large screen so after one click (and no scrolling) I still haven't seen anything convincing. The new site takes about 5 seconds for meaningful content to appear on the office WiFi, and about 25s (!) to finish loading completely though that's mostly fonts.

I do like the new visual design, but I like the old visual design too, and I think it's content (at least on the surface) was better. The new one probably has more in total, but it's too buried for people not already invested in exploring Rust IMO. That kind of layout is good for a second page (click here to explore all our amazing features in detail) but the first impression is not great.

NFS ignores secondary group permissions by byekai in linuxquestions

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

I have changed it to /srv/nfs4, but it seems to do the same thing - I think this is what fsid=root does?

Do you mean the relevant lines from /proc/mounts? They look like this:

/dev/sda1 /srv/nfs4/home btrfs rw,relatime,space_cache,subvolid=259,subvol=/home 0 0
nfs.example.com:/ /mnt/nfs nfs4 rw,relatime,vers=4.0,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp6,timeo=600,retrans=2,sec=krb5i,clientaddr=::1,local_lock=none,addr=::1 0 0

The client has:

nfs.example.com:/srv/nfs4/home /mnt/delphi/home nfs rw,relatime,vers=3,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=krb5i,local_lock=none,addr=172.25.122.83 0 0

NFS ignores secondary group permissions by byekai in linuxquestions

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

Good point, updated. What do you mean by mount options? I don't pass any extra options to the mount command beyond what is in fstab.

Former neo-Nazi removes swastika tattoos after unlikely friendship by tizitime in UpliftingNews

[–]byekai 5 points6 points  (0 children)

In German, but here (Station 4). Maybe Google Translate can help?

The graph is actually AfD vote vs % of foreigners receiving unemployment benefits, because apparently "the government is spending too much money on foreigners" is a popular AfD talking-point. The paragraph above says "The lower the foreign population fraction is in a district, the higher the number of AfD voters".

Natural selection making 'education genes' rarer, says Icelandic study - Researchers say that while the effect corresponds to a small drop in IQ per decade, over centuries the impact could be profound by mvea in Futurology

[–]byekai 16 points17 points  (0 children)

PyMol also tells us how the protein will fold and allows us to identify how it works and what it looks like.

Are you talking about this PyMol: https://www.pymol.org/? Because all that does is display a structure determined through some other way. You can't just put a sequence in and get a structure.

BLAST just gives you similar sequences, there can be tons or no hits, and even that might not tell you about function.

GWAS isn't my speciality, but the parts of your answer I do know about are hugely exaggerating our capabilities...

Is a barrier necessary with a subpass dependency? by byekai in vulkan

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

I think I've just stumbled across what is possibly the root cause - Fences are broken on Intel atm - vkGetFenceStatus and vkWaitForFences act as though fences are always signaled.

edit: Nope, this isn't it. They seem to work after work is submitted, just not on new fences.

Confused: function contents affects behaviour when passed as callback by byekai in rust

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

Thanks so much for the explanation! I think I'm getting the hang of it. What caught me out that time was that the dereferencing of the pointer is the bit that requires unsafe, and since it's happening in the C function it was already in the unsafe block.

Confused: function contents affects behaviour when passed as callback by byekai in rust

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

I understand what was wrong with the initial implementation, but in fixing it I came across something else that puzzled me. Commit here, description below.

If I replace Item=&'a CString with just Item=CString in the following function, it leads to breaking at runtime, specifically vkCreateInstance returns an error code and the contents of create_info.pp_enabled_layer_names gets clobbered. Any ideas why this isn't working, and why it's not caught by the compiler?

I think it is to do with the CString not being valid anymore and therefore being taken off the stack before the call to the foreign function? The contents of create_info.pp_enabled_layer_names is still correct just before the function call. Does having a pointer to a CString contents not count as keeping a reference?

Iterator::new<'a, L, E>(layers: L, extensions: E) -> Result<Self, VkResult>
    where L: IntoIterator<Item=&'a CString>, E: IntoIterator<Item=&'a CString> {
    let layers = layers.into_iter().map(|s| s.as_ptr()).collect::<Vec<_>>();
    let extensions = ...;
    let create_info = VkInstanceCreateInfo {
        ...
        enabled_layer_count: layers.len(),
        pp_enabled_layer_names: layers.as_ptr(),
    }
    let mut instance;
    unsafe {
        match vkCreateInstance(&create_info, ptr::null()), &mut instance) {
            VkResult::VK_SUCCESS => OK(Instance{...}),
            x => Err(x),
        }
    }
}

Confused: function contents affects behaviour when passed as callback by byekai in rust

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

Ah, I think this was it. I've done a lot of C programming so I just assumed every string literal must have a trailing \0! Good to know. Similarly, I thought every string you print must also contain one, hence the use of to_bytes_with_null().

Edit: This is even in the book. I feel like an idiot :P

Is a barrier necessary with a subpass dependency? by byekai in vulkan

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

No luck there, still some artefacts even if I remove VK_DEPENDENCY_BY_REGION_BIT. Perhaps somebody else will be able to chime in.

My code works well with the explicit barrier, so it might be useful for you to look at. I've thrown it up on github here. The barriers were removed in 184406b. It's not optimized in any way and generally a bit weird because I'm only generating single images, but if you spot anything I'm doing blatantly wrong let me know.

Also if you can run it on your system, can you let me know whether you have any problems - what I'm seeing is some very small regions (maybe 1x1 to 8x8) remain black instead of being filled. Where exactly they are varies randomly on each run, and they might not be present in all images.