HNHacker News
TopNewBestAskShowJobs

drran

1,205 karma · joined July 10, 2019

submissionscomments
drran··on Why asynchronous Rust doesn't work
What the problem with trees? They are trees, not cyclic graphs.
drran··on Rust data structures with circular references
I tried to implement removing of elements from the tree, just as an exercise, and I see no problems with borrow checker at all. I use Rust since version 1.0, so borrow checker is my friend.

Rebalancing of the left branch is a bit complicated, so I implemented just detach() method, which takes out the element with it subbranches from the tree. From there, you can implement your favorite deletion method. For production, I will just mark a node as deleted and then compact the tree later, to have predictable timings.

drran··on Sign arbitrary data with your SSH keys
GitHub can alter the CODE. Why it should play with just a key? If GitHub wants to pwn the whole world, it can do it right now.
drran··on Rust data structures with circular references
Tree and Node must own subnodes, but node need just to point to parent, it cannot own parent.

  #[derive(Debug)]
  struct Node {
    data: i32,

    left: Option<Box<Node>>,
    right: Option<Box<Node>>,
    parent: Option<*mut Node>,
  }
  
  impl Node {
    pub fn new_root(data: i32) -> Self {
        Node { data, left: None, right: None, parent: None, }
    }

    pub fn new_leaf(data: i32, parent: *mut Node) -> Self {
        Node { data, left: None, right: None, parent: Some(parent), }
    }
  }

  #[derive(Debug)]
  struct Tree {
    root: Option<Node>,
  }

  impl Tree {
    pub fn new() -> Self {
        Tree { root: None }
    }

    pub fn insert(&mut self, data: i32) -> bool {
        match self.root {
            Some(ref mut node) => Tree::insert_at(node, data),
            None => {
                self.root = Some(Node::new_root(data));
                true
            }
        }
    }

    fn insert_at(current_node: &mut Node, data: i32) -> bool {
        match (
            current_node.left.as_deref_mut(),
            current_node.right.as_deref_mut(),
        ) {
            _ if data == current_node.data => false,

            (Some(left_node), _) if data < current_node.data => Tree::insert_at(left_node, data),

            (None, _) if data < current_node.data => {
                let new_node = Node::new_leaf(data, current_node);
                current_node.left = Some(Box::new(new_node));
                true
            }

            (_, Some(right_node)) => Tree::insert_at(right_node, data),

            (_, None) => {
                let new_node = Node::new_leaf(data, current_node);
                current_node.right = Some(Box::new(new_node));
                true
            }
        }
    }

  }

  pub fn main() {
    let mut tree = Tree::new();
    let data = [5, 3, 65, 123, 6, 11, 3, 1, 5, 42];

    for i in data {
        tree.insert(i);
    }

    println!("{:?}", tree);
  }
drran··on Why Lisp?
Rare example of broken backward compatibility: `cargo install gltf-viewer` doesn't work today because of an error in gltf library. The error is fixed, but gltf-viewer is not updated to use the fix.

   Compiling gltf v0.11.3
  error[E0597]: `buf` does not live long enough
   --> /home/vlisivka/.cargo/registry/src/github.com-1ecc6299db9ec823/gltf-0.11.3/src/binary.rs:225:35
      |
  119 | impl<'a> Glb<'a> {
      |      -- lifetime `'a` defined here
  ...
  225 |                     Self::from_v2(&buf)
      |                     --------------^^^^-
      |                     |             |
      |                     |             borrowed value does not live long enough
      |                     argument requires that `buf` is borrowed for `'a`
  ...
  233 |             }
      |             - `buf` dropped here while still borrowed
drran··on Skeptical about electric-powered planes
https://patents.google.com/patent/US10507452B2/en
drran··on Skeptical about electric-powered planes
LENR scientists are using palladium and nickel to compress hydrogen up to 100k atmospheres (90 hydrogen atoms per 1 atom of palladium) at room temperature and pressure.
drran··on A 100LOC C impl of memset, that is faster than glibc's
Just implement a driver for your memory controller and update all software to use syscall into kernel (about 10k total instructions per syscall), which will perform memset or memcpy, then measure performance improvement and tell it to us.
drran··on Useful sed scripts and patterns
StackOverflow
drran··on The Invisible JavaScript Backdoor
OK, OK, we can start with a warning in the compiler that use of any language except English is unsafe.
drran··on Write thin to write fast
It depends. Japanese, Chinese, Korean, Mongolian, etc. writers are using vertical layout for text without problem.

https://www.w3.org/International/articles/vertical-text/

drran··on The Invisible JavaScript Backdoor
Most code made by English speakers contains English word and Latin characters, so other languages and alphabets must be abandoned, and their native speakers must imprisoned until they understand their mistakes.
drran··on Macron says France will build new nuclear energy reactors
Uranium can be used to create weapons, so we don't want to allow Uranium mining everywhere except a few safe spots. If demand for Uranium will increase, then price for Uranium will skyrocket (buyer marker will switch to seller market) and will match prices for other kinds of energy.
drran··on Use forums rather than Slack/Discord to support developer community
Check your internet connection and Google/Gmail certificates. It looks like you are taped.
drran··on Time Travel: Probability and Impossibility
Imagine that you have pair of socks. You sent one sock to Alice and the second sock to Bob. When Alice opened her package, she sees the left sock, so she immediately knows that Bob received the right sock. This is the FTL communication.

Alice can forcefully change her sock from left sock to right sock and back, e.g. by putting sock to the corresponding foots, but Bob will never know that.

drran··on Time Travel: Probability and Impossibility
> When clock travel faster than speed of light it catches up with the previous light showing clock earlier time.

I can just record the clock and replay the record. It makes back-in-time travel much simpler then.

drran··on The popularity of e-bikes isn’t slowing down
I use steel chain with steel lock[0] for last 5 years. No problems so far.

[0]: https://ae01.alicdn.com/kf/HTB1UMz3k8yWBuNkSmFPq6xguVXar/1pc...

drran··on Iraqi Prime Minister survives exploding drone assassination attempt
Terror is a tool of war. If winning of a war is not a goal, then it just pure terror, and inducing it is terrorism.
drran··on Decline in effectiveness of all three US Covid-19 vaccines over time
If you survived Covid without complications, you should not fear a vaccine, because it contains parts of the virus you're already exposed to, so nothing new for your body.
drran··on Decline in effectiveness of all three US Covid-19 vaccines over time
Efficacy != efficiency.

Efficacy is just estimation after some tests. It must be at least 50% for vaccine to be accepted. 95% is bigger than 50%.

drran··on Stop Making Students Use Eclipse (2020)
Why not to use `perf` to figure out why Eclipse is slow, fix the problem, and then send a patch?
drran··on Nitrogen fertilizer shortage threatens to cut global crop yields – CF Industries
I have no car, I don't fly on planes, I don't want to have a nuclear station near to me.
drran··on Nitrogen fertilizer shortage threatens to cut global crop yields – CF Industries
Radiation poisoning has a long tail, so it hard to calculate how many were killed by cancer and for how long. It doesn't mean that we easily discard long-term safety when talking about nuclear power.
drran··on Nitrogen fertilizer shortage threatens to cut global crop yields – CF Industries
Yep. Few more Chornobyls, and CO2 level will plummet back to 200ppm then.
drran··on Micro – a modern and intuitive terminal-based text editor
mc + mcedit is much better for those, who came from DOS camp.
drran··on Why is Delta so infectious? New tool spotlights little-noticed mutation
Science (all about profs) is opposite to belief (acceptance without proof).

«Some folks, which are used to use proofs, are accepting something without proof...» Emmm...

drran··on Why is Delta so infectious? New tool spotlights little-noticed mutation
SARS CoV research is already banned in USA, so they paid China to do research. It helped China a lot to protect their country.
drran··on Some Whales Can Eat Upwards of 16 Tons of Tiny Shrimp a Day
It's hard to find bugs now, because they are killed by insecticides/pesticides.
drran··on Elements may have been forged on Earth, as well as in space
Google «test for clay in soil» and then perform the same experiment in your garden. You will see with your own eyes how easy it is for molted elements to separate into layers.
drran··on Ask HN: What you up to? (Who doesn't want to be hired?)
StagesCycling Dash L50/M50 are open to hack: bootloader is not protected, SD card can be replaced, and ssh access is open (when device is connected by USB).
← PreviousPage 17 of 34Next →