jado's Avatar

jado

@jadon.io

https://jadon.io https://github.com/phase

74
Followers
229
Following
52
Posts
27.02.2024
Joined
Posts Following

Latest posts by jado @jadon.io

Post image

i don't know much
but I feel a lot ✢

29.01.2025 22:09 πŸ‘ 5504 πŸ” 1142 πŸ’¬ 16 πŸ“Œ 2
Video thumbnail

WIFI #animation #flipnote #3ds

24.01.2025 20:54 πŸ‘ 1019 πŸ” 162 πŸ’¬ 5 πŸ“Œ 1

i must write proofs with these. surely the joker is the axiom of choice

06.01.2025 01:31 πŸ‘ 2 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Post image

oh man the character.ai lawsuit is SO much worse than the headlines made it out to be:

11.12.2024 23:57 πŸ‘ 382 πŸ” 137 πŸ’¬ 9 πŸ“Œ 18

the header overflows for me but otherwise perfect

01.01.2025 02:01 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Post image

gandi did not autorenew **again**

29.12.2024 18:11 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

there's now a sidebar for image/polygon layers, and you can export them as GeoJSON

28.12.2024 22:33 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
browser icon with green tick, cloud icon with two green ticks, another cloud icon with two green ticks, server icon with one green tick and one red cross

browser icon with green tick, cloud icon with two green ticks, another cloud icon with two green ticks, server icon with one green tick and one red cross

21.12.2024 15:22 πŸ‘ 242 πŸ” 75 πŸ’¬ 9 πŸ“Œ 3

wow fuck cmake

21.12.2024 02:53 πŸ‘ 13 πŸ” 1 πŸ’¬ 2 πŸ“Œ 0

the REST API also has this data, but if you hit this endpoint normally you'll get all the stars *without the starred_at field* unless you include the custom header `Accept: application/vnd.github.star+json`.

sadly I didn't learn this until after making the graphql scripts

20.12.2024 06:15 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Starlog

just opened the site starlog.jadon.io

the repo has a script to gen a json but here's the graphql for it: github.com/phase/starlo... it takes about 5 secs/100 stars for me. yours especially took a long time lmao

20.12.2024 06:10 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Post image Post image

here's one from iOS dev -> Rustaholic with a bunch of Julia sprinkled in?

19.12.2024 05:38 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Post image

I love that with some people you can see large transitions like switching from JS to Rust

19.12.2024 05:30 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Post image Post image

@nikiv.dev has starred 50k projects... i am astonished this is real data...

19.12.2024 05:28 πŸ‘ 1 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Post image

building a github star calendar & it looks pretty good! you can hover over each day to get links to what you starred.

19.12.2024 05:24 πŸ‘ 0 πŸ” 0 πŸ’¬ 2 πŸ“Œ 0
Post image

🌠

16.12.2024 11:19 πŸ‘ 1 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
Post image

a more useful example. the point placing is wonky because the leaflet plugins are not playing nicely together.

09.12.2024 06:45 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 1

ArcGIS might also do it but wow is the UI tricky to navigate.. I'm noticing a trend with these geospacial tools

09.12.2024 06:05 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Post image

i tried a dozen different tools to do this & all of them could do 10-80% of *that one thing i needed*

QGIS might do this but it's nonfunctional for me - zooming is broken and everything is incredibly slow. the amount of icons on top is frightening

09.12.2024 05:53 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
Post image

a map with images that you can draw polygons on

09.12.2024 05:40 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

jk pls break more i love the updates πŸ™

29.11.2024 03:15 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

bruh it’s thanksgiving stop breaking my code 😭

29.11.2024 02:57 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0
#[cfg(test)]
mod tests {
    use super::*;
    use reader::read_class::read_class;

    #[test]
    fn test_write_class() {
        let mut expected_class = ClassFile::new(ClassVersion::JDK_11, "example/Foo");
        expected_class.add_interface("example/IFoo");

        let mut buf = vec![0; 1024];
        write_class(&expected_class, &mut buf);

        let actual_class = read_class(&mut buf).expect("failed to read class");
        assert_eq!(expected_class, actual_class);
    }
}

#[cfg(test)] mod tests { use super::*; use reader::read_class::read_class; #[test] fn test_write_class() { let mut expected_class = ClassFile::new(ClassVersion::JDK_11, "example/Foo"); expected_class.add_interface("example/IFoo"); let mut buf = vec![0; 1024]; write_class(&expected_class, &mut buf); let actual_class = read_class(&mut buf).expect("failed to read class"); assert_eq!(expected_class, actual_class); } }

took a detour into making a new crate for jvm bytecode parsing & emitting

27.11.2024 07:30 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0
/// A thread-safe interner that requires a 'static lifetime.
pub struct StaticInternMap {
    map: RwLock<StringInternMap>,
}

impl StaticInternMap {
    pub fn new(capacity: usize) -> StaticInternMap {
        StaticInternMap { map: RwLock::new(StringInternMap::with_capacity(capacity)) }
    }

    /// Intern a string, returning a yarn.
    /// The yarn is always 128 bits long and may be an inlined string (where len < SSO_LEN)
    ///  or a &'static str pointing into a buffer.
    /// Safety: &'static self is required because the allocated strings the Yarns may point to
    ///  need to live for the lifetime of the program.
    pub fn intern(&'static self, name: &str) -> Yarn {
        if let Some(yarn) = Yarn::inlined(name) {
            return yarn;
        }

        // Safety: Yarn is assuming this 'static lifetime we pass it will never be dropped.
        // The 'static lifetime within the StringInternMap is only valid
        // for the life of the map instance, because the String buffers
        // being pointed to are *owned* by the map.
        unsafe {
            // grab read lock, get existing interned string that matches
            let map = self.map.read().expect("can't grab lock");
            if let Some(ptr) = map.find_existing(name) {
                return Yarn::from_static(ptr);
            }
            drop(map);

            // not already interned, grab write lock
            let mut map = self.map.write().expect("can't grab lock");
            let id = map.store(name);
            let ptr: &'static str = map.lookup_unchecked(id);
            return Yarn::from_static(ptr);
        }
    }
}

static STATIC_MAP: LazyLock<StaticInternMap> = LazyLock::new(|| StaticInternMap::new(1024));

pub fn intern(name: &str) -> Yarn {
    STATIC_MAP.intern(name)
}

/// A thread-safe interner that requires a 'static lifetime. pub struct StaticInternMap { map: RwLock<StringInternMap>, } impl StaticInternMap { pub fn new(capacity: usize) -> StaticInternMap { StaticInternMap { map: RwLock::new(StringInternMap::with_capacity(capacity)) } } /// Intern a string, returning a yarn. /// The yarn is always 128 bits long and may be an inlined string (where len < SSO_LEN) /// or a &'static str pointing into a buffer. /// Safety: &'static self is required because the allocated strings the Yarns may point to /// need to live for the lifetime of the program. pub fn intern(&'static self, name: &str) -> Yarn { if let Some(yarn) = Yarn::inlined(name) { return yarn; } // Safety: Yarn is assuming this 'static lifetime we pass it will never be dropped. // The 'static lifetime within the StringInternMap is only valid // for the life of the map instance, because the String buffers // being pointed to are *owned* by the map. unsafe { // grab read lock, get existing interned string that matches let map = self.map.read().expect("can't grab lock"); if let Some(ptr) = map.find_existing(name) { return Yarn::from_static(ptr); } drop(map); // not already interned, grab write lock let mut map = self.map.write().expect("can't grab lock"); let id = map.store(name); let ptr: &'static str = map.lookup_unchecked(id); return Yarn::from_static(ptr); } } } static STATIC_MAP: LazyLock<StaticInternMap> = LazyLock::new(|| StaticInternMap::new(1024)); pub fn intern(name: &str) -> Yarn { STATIC_MAP.intern(name) }

#[cfg(test)]
mod test_intern {
    use super::*;
    use std::ptr;

    /// 16 (u128) on 64-bit machines, 8 (u64) on 32-bit machines
    const SIZE_OF_YARN: usize = mem::size_of::<Yarn>();

    #[test]
    fn test_inline() {
        let a = "aa".intern();
        let b = "bb".intern();

        // check values
        assert_eq!(a, "aa");
        assert_eq!(b, "bb");
        assert_eq!(a.as_str(), "aa");
        assert_eq!(b.as_str(), "bb");

        // check addresses
        let a_addr: usize = ptr::addr_of!(*a).addr();
        let b_addr: usize = ptr::addr_of!(*b).addr();
        // these yarns are inlined, so they don't have the same address
        //  (& are stored sequentially on the stack)
        assert_eq!(a_addr + SIZE_OF_YARN, b_addr, "yarns are not inlined");
    }

    #[test]
    fn test_intern() {
        let value = "getInstanceOfSomeClass()Ljava/lang/String;";
        let a = value.intern();
        let b = value.intern();

        // check values
        assert_eq!(a, b);
        assert_eq!(a.as_str(), b.as_str());

        // the string is in the cache
        let len = STATIC_MAP.map.read().expect("cant get lock").map.len();
        assert!(len > 0);

        // check addresses
        let a_addr: usize = ptr::addr_of!(*a).addr();
        let b_addr: usize = ptr::addr_of!(*b).addr();
        // these yarns are interned, so they have the same address
        //  (& is guarenteed to be 'static)
        assert_eq!(a_addr, b_addr, "yarns are not interned to the same allocation");
    }

#[cfg(test)] mod test_intern { use super::*; use std::ptr; /// 16 (u128) on 64-bit machines, 8 (u64) on 32-bit machines const SIZE_OF_YARN: usize = mem::size_of::<Yarn>(); #[test] fn test_inline() { let a = "aa".intern(); let b = "bb".intern(); // check values assert_eq!(a, "aa"); assert_eq!(b, "bb"); assert_eq!(a.as_str(), "aa"); assert_eq!(b.as_str(), "bb"); // check addresses let a_addr: usize = ptr::addr_of!(*a).addr(); let b_addr: usize = ptr::addr_of!(*b).addr(); // these yarns are inlined, so they don't have the same address // (& are stored sequentially on the stack) assert_eq!(a_addr + SIZE_OF_YARN, b_addr, "yarns are not inlined"); } #[test] fn test_intern() { let value = "getInstanceOfSomeClass()Ljava/lang/String;"; let a = value.intern(); let b = value.intern(); // check values assert_eq!(a, b); assert_eq!(a.as_str(), b.as_str()); // the string is in the cache let len = STATIC_MAP.map.read().expect("cant get lock").map.len(); assert!(len > 0); // check addresses let a_addr: usize = ptr::addr_of!(*a).addr(); let b_addr: usize = ptr::addr_of!(*b).addr(); // these yarns are interned, so they have the same address // (& is guarenteed to be 'static) assert_eq!(a_addr, b_addr, "yarns are not interned to the same allocation"); }

switched to byteyarn + a global intern map. small enough strings are inlined while large strings are interned

23.11.2024 04:34 πŸ‘ 2 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

/// Like a Cow<'a, str> but you can plug in your own type.
#[derive(Yokeable)]
pub enum Ident<'a, O> {
    Owned(O),
    Borrowed(&'a str),
}

impl<'a, O: Clone + From<&'a str>> Ident<'a, O> {
    pub fn new(s: &'a str) -> Self {
        Ident::Borrowed(s)
    }

    pub fn as_owned(&self) -> O {
        match self {
            Ident::Owned(s) => s.clone(),
            Ident::Borrowed(s) => (*s).into(),
        }
    }

    /// Any lifetime 'b is fine here because we're always returning an owned ustr.
    pub fn mutate<'b>(&mut self, f: impl FnOnce(&mut O)) -> Ident<'b, O> {
        let mut owned = self.as_owned();
        f(&mut owned);
        Ident::Owned(owned)
    }
}

/// C is our cart, could be an Arc<[u8]> or something.
pub struct ID<C>(Yoke<Ident<'static, Ustr>, C>);

impl<C> ID<C> {
    pub fn as_str(&self) -> &str {
        let ident = self.0.get();
        match ident {
            Ident::Owned(s) => s.as_str(),
            Ident::Borrowed(s) => s,
        }
    }
}

pub struct ClassFile<C> {
    name: ID<C>,
}

/// Like a Cow<'a, str> but you can plug in your own type. #[derive(Yokeable)] pub enum Ident<'a, O> { Owned(O), Borrowed(&'a str), } impl<'a, O: Clone + From<&'a str>> Ident<'a, O> { pub fn new(s: &'a str) -> Self { Ident::Borrowed(s) } pub fn as_owned(&self) -> O { match self { Ident::Owned(s) => s.clone(), Ident::Borrowed(s) => (*s).into(), } } /// Any lifetime 'b is fine here because we're always returning an owned ustr. pub fn mutate<'b>(&mut self, f: impl FnOnce(&mut O)) -> Ident<'b, O> { let mut owned = self.as_owned(); f(&mut owned); Ident::Owned(owned) } } /// C is our cart, could be an Arc<[u8]> or something. pub struct ID<C>(Yoke<Ident<'static, Ustr>, C>); impl<C> ID<C> { pub fn as_str(&self) -> &str { let ident = self.0.get(); match ident { Ident::Owned(s) => s.as_str(), Ident::Borrowed(s) => s, } } } pub struct ClassFile<C> { name: ID<C>, }

i think im yoking correctly?

21.11.2024 15:09 πŸ‘ 0 πŸ” 1 πŸ’¬ 1 πŸ“Œ 0
ustr - Rust Fast, FFI-friendly string interning. A `Ustr` (Unique Str) is a lightweight handle representing a static, immutable entry in a global string cache, allowing for:

instead of using a Cow<'a, str> here, I'm using ustr to intern strings with a global cache. Ident here can use other owned types too so I can compare different interning solutions

docs.rs/ustr/latest/...

21.11.2024 15:13 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

the goal here is to have strings inside the ClassFile be either 1) borrowing data from some "cart" (original loaded/mmapped class bytes) or 2) an owned string.

21.11.2024 15:09 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0

/// Like a Cow<'a, str> but you can plug in your own type.
#[derive(Yokeable)]
pub enum Ident<'a, O> {
    Owned(O),
    Borrowed(&'a str),
}

impl<'a, O: Clone + From<&'a str>> Ident<'a, O> {
    pub fn new(s: &'a str) -> Self {
        Ident::Borrowed(s)
    }

    pub fn as_owned(&self) -> O {
        match self {
            Ident::Owned(s) => s.clone(),
            Ident::Borrowed(s) => (*s).into(),
        }
    }

    /// Any lifetime 'b is fine here because we're always returning an owned ustr.
    pub fn mutate<'b>(&mut self, f: impl FnOnce(&mut O)) -> Ident<'b, O> {
        let mut owned = self.as_owned();
        f(&mut owned);
        Ident::Owned(owned)
    }
}

/// C is our cart, could be an Arc<[u8]> or something.
pub struct ID<C>(Yoke<Ident<'static, Ustr>, C>);

impl<C> ID<C> {
    pub fn as_str(&self) -> &str {
        let ident = self.0.get();
        match ident {
            Ident::Owned(s) => s.as_str(),
            Ident::Borrowed(s) => s,
        }
    }
}

pub struct ClassFile<C> {
    name: ID<C>,
}

/// Like a Cow<'a, str> but you can plug in your own type. #[derive(Yokeable)] pub enum Ident<'a, O> { Owned(O), Borrowed(&'a str), } impl<'a, O: Clone + From<&'a str>> Ident<'a, O> { pub fn new(s: &'a str) -> Self { Ident::Borrowed(s) } pub fn as_owned(&self) -> O { match self { Ident::Owned(s) => s.clone(), Ident::Borrowed(s) => (*s).into(), } } /// Any lifetime 'b is fine here because we're always returning an owned ustr. pub fn mutate<'b>(&mut self, f: impl FnOnce(&mut O)) -> Ident<'b, O> { let mut owned = self.as_owned(); f(&mut owned); Ident::Owned(owned) } } /// C is our cart, could be an Arc<[u8]> or something. pub struct ID<C>(Yoke<Ident<'static, Ustr>, C>); impl<C> ID<C> { pub fn as_str(&self) -> &str { let ident = self.0.get(); match ident { Ident::Owned(s) => s.as_str(), Ident::Borrowed(s) => s, } } } pub struct ClassFile<C> { name: ID<C>, }

i think im yoking correctly?

21.11.2024 15:09 πŸ‘ 0 πŸ” 1 πŸ’¬ 1 πŸ“Œ 0

the new render state abstractions are great tho. glad we’re moving off of hard references to objs within rendering code (Player -> PlayerRenderState, ItemStack -> ItemClusterRenderState).

20.11.2024 16:50 πŸ‘ 0 πŸ” 0 πŸ’¬ 0 πŸ“Œ 0

blessed slicedlime breaking my code once again πŸ™

20.11.2024 16:47 πŸ‘ 0 πŸ” 0 πŸ’¬ 1 πŸ“Œ 0