Profile for hikari

Header for hikari
Avatar for hikari
Display name
hikari 🌟
Username
@hikari@noyu.me
Role
admin

About hikari

Bio

from another world; anime girls on the internet who are terrible at playing guitar and slightly less bad at programming; EN/SV/DE/日本語

Stats

Joined
Posts
17739
Followed by
1566
Following
197

Recent posts

I don’t know who needs to hear this, but

trait FooBar: Any {
  fn as_any(&self) -> &dyn Any {
    &self as &dyn Any
  }
}

sadly will not work, no matter how many apostrophes you add. you also can’t just call .downcast_ref() on a FooBar.

previously, when having to do this, i just gave up.

but it turns out there’s a practical workaround:

trait FooBar: Any {}
pub trait AnyFooBar {
    fn as_any<'a>(&'a self) -> &'a (dyn std::any::Any + 'static);
}   
impl<T: FooBar> AnyFooBar for T {
    fn as_any<'a>(&'a self) -> &'a (dyn std::any::Any + 'static) {
        &*self
    }   
}

I hope this helps avoid suffering for someone else!

Open thread at this post

forming a gang of soft scientists from subfields that are empirically verifiable. we’re gonna go crash the hard scientists’ party by screaming at them about their unfalsifiable subfields. let’s go

Open thread at this post

i will stab the next person who tells me that there are hard and soft sciences and the distinction is whether you can empirically verify propositions. every scientific field has some degree of unfalsifiability lurking within it. i may or may not just be bitter because my degree is in linguistics which is supposedly a soft science, and so many STEM-bros do not realise that we too have experimentally verifiable propositions. it’s easier to prove various facts about language development than it is to prove your pharmaceutical works

Open thread at this post

i set a limit on how many concurrent requests nginx will proxy to GoToSocial, let’s see if that saves my server from certain death the next time marcan replies to me lol

(i deleted the original post i made about this problem and it seems like it took the thread with it? i’m very confused…)

Open thread at this post

suppose I want to implement a memory allocator, and I want to optimise for simplicity, clarity and ease-of-implementation, rather than being optimally efficient. what is a good strategy? I do need to handle a mix of small and large allocations and freeing needs to work.

Open thread at this post
#import "Foundation/Foundation.h"

#include <objc/message.h>
#include <objc/runtime.h>

@interface Infinite: NSObject
@end

@implementation Infinite: NSObject
@end

int main(void)
{
    class_addMethod([Infinite self], @selector(loop), objc_msgSend, "@@:");
    [[Infinite new] loop];
    return 0;
}
Open thread at this post