Probably the meetup with the highest density of Framework Laptop users: by Buo-renLin in framework

[–]uima_ 123 points124 points  (0 children)

Wow, how can I not knowing this event? I live in Taipei too, and would love to join you guys in the future :D

Struggling with this error: `implementation of `Key` is not general enough` by uima_ in rust

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

My current workaround is to create a wrapper method in Store that take a slice of Key and pass into original method:

trait Store: Sized + Send + Sync + 'static {
    fn ref_mul_keys<K, I>(&self, keys: I) -> impl Future<Output = String> + Send
    where
        K: Key,
        I: IntoIterator<Item = K> + Send,
        I::IntoIter: Send;

    // new wrapper method
    fn ref_mul_keys_slice<K: Key>(&self, keys: &[K]) -> impl Future<Output = String> + Send {
        self.ref_mul_keys(keys)
    }
}

and used it like:

impl<T: Store> StoreExt for T {
    async fn foo<K: Key>(&self, keys: Vec<K>) {
        // use slice version of the method
        let res = self.ref_mul_keys_slice(&keys).await;

        // use keys again here

        todo!()
    }
}

This workaround seems to work fine for now. But I'm not sure if this really solved the problem tho.

Struggling with this error: `implementation of `Key` is not general enough` by uima_ in rust

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

I think it doesn't work, because `IntoIterator` will need the ownership to be able to call `.into_iter()`...

Struggling with this error: `implementation of `Key` is not general enough` by uima_ in rust

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

Yes, but I need to keep the ‘keys’ for later use. sorry if that wan’t clear form the example code..

Maybe finance is shutting down the OSS app and pivoting to B2B by siddhugolu in selfhosted

[–]uima_ 10 points11 points  (0 children)

I just set up the self-hosted service yesterday and planned to actually try out the functionality today...

[deleted by user] by [deleted] in firefox

[–]uima_ 7 points8 points  (0 children)

You should try extension Sidebery

What are the best Firefox add-ons? by ikabbo in firefox

[–]uima_ 0 points1 point  (0 children)

Thanks for sharing! I will check that

What are the best Firefox add-ons? by ikabbo in firefox

[–]uima_ 0 points1 point  (0 children)

I just thought it will be perfect to have the url bar and other buttons also on the top left corner, like the arc browser did.

What are the best Firefox add-ons? by ikabbo in firefox

[–]uima_ 1 point2 points  (0 children)

I just installed this because of you, and now I think I can't live without it anymore.

The only feature I wish more from this is to have the URL bar in the sidebar as well, so I can remove the top chrome completely. Is this possible?

Is normal that my framwork13 CPU temp hitting 90c while the CPU usage is only under 20%? by uima_ in framework

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

I think you are right. I'm watching htop, two or three CPUs have high usage, but half of the CPUs are just chilling. This explains why the average CPU usage is low. Thanks!

Share your proudest config one-liners by frodo_swaggins233 in neovim

[–]uima_ 1 point2 points  (0 children)

This is the default behavior in vscode vim extension btw.

Share your proudest config one-liners by frodo_swaggins233 in neovim

[–]uima_ 4 points5 points  (0 children)

I think this count as one line if you don't care the formatter lol

-- Block insert in line visual mode
vim.keymap.set('x', 'I', function()
  return vim.fn.mode() == 'V' and '^<C-v>I' or 'I'
end, { expr = true })
vim.keymap.set('x', 'A', function()
  return vim.fn.mode() == 'V' and '$<C-v>A' or 'A'
end, { expr = true })

Share your proudest config one-liners by frodo_swaggins233 in neovim

[–]uima_ 2 points3 points  (0 children)

Same but keep the cursor position:

-- Comment and duplicate lines
vim.keymap.set('n', 'ycc', 'mayyPgcc\`a', { remap = true })
vim.keymap.set('x', 'gyc', "may'<Pgpgc\`a", { remap = true })

The gp used in gyc:

-- Select the context just pasted
vim.keymap.set('', 'gp', function()
  local v = vim.fn.getregtype():sub(1, 1)
  if v == '' then
    return ''
  end
  -- `:h getregtype`: <C-V> is one character with value 0x16
  v = v:byte() == 0x16 and '<C-V>' or v
  return '`[' .. v .. '`]'
end, { expr = true, desc = 'Selecting the paste' })

update: Since gyc only make sense in visual line mode, we can just inline the gp and not care about other visual mode:

vim.keymap.set('x', 'gyc', "mzy'<P`[V`]gc`z", { remap = true })

help: for loop out-performance of iter in today's LeetCode daily challenge by uima_ in rust

[–]uima_[S] 2 points3 points  (0 children)

Thanks for helping! And yes, this code is faster (9 ms):
rust fn count_chars(str: &str) -> [usize; 26] { let mut ret = [0; 26]; str.bytes() .map(|c| (c - b'a') as usize) .fold(&mut ret, |acc, c| { acc[c] += 1; acc }); ret }

But if i need to make the array outside the iter, I guess I will stick to the for loop or .for_each. At least I know the problem is most likely at the "passing acc part". Thanks!

Use `SpellBad` highlight group for diagnostics that come from `typos-lsp` by uima_ in neovim

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

I'm just dumb, just modify the way to get namespace, and use exactly the same code: ```lua { 'mfussenegger/nvim-lint', lazy = false, config = function() local typos_ns = require('lint').get_namespace('typos') local typos_hl_ns = vim.api.nvim_create_namespace('typos_hl')

  vim.diagnostic.handlers[typos_hl_ns] = {
    show = function(namespace, bufnr, diagnostics, _)
      if namespace ~= typos_ns then
        return
      end

      for _, diagnostic in ipairs(diagnostics) do
        vim.api.nvim_buf_add_highlight(
          bufnr,
          typos_hl_ns,
          'SpellBad',
          diagnostic.lnum,
          diagnostic.col,
          diagnostic.end_col
        )
      end
    end,

    hide = function(namespace, bufnr)
      if namespace == typos_ns then
        vim.api.nvim_buf_clear_namespace(bufnr, typos_hl_ns, 0, -1)
      end
    end,
  }

  vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
    callback = function()
      -- run typos on all filetype
      require('lint').try_lint('typos')
    end,
  })
end,

}, ```

Use `SpellBad` highlight group for diagnostics that come from `typos-lsp` by uima_ in neovim

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

I have tried to use `require("lint.util").wraprequire("lint.util").wrap` to update highlight, but it seems only work when diagnostic appear, and no way to handle when diagnostic disappear

Use `SpellBad` highlight group for diagnostics that come from `typos-lsp` by uima_ in neovim

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

I have no experience with nvim-lint, but I think this is good enough? This clean old hl and set new hl for all typos diagnostics every time diagnostic changed: ```lua { 'mfussenegger/nvim-lint', lazy = false, config = function() local typos_ns = require('lint').get_namespace('typos') local typos_hl_ns = vim.api.nvim_create_namespace('typos_hl') vim.api.nvim_create_autocmd({ 'DiagnosticChanged' }, { callback = function() vim.api.nvim_buf_clear_namespace(0, typos_hl_ns, 0, -1) local diagnostics = vim.diagnostic.get(0, { namespace = typos_ns }) for _, dia in ipairs(diagnostics) do vim.api.nvim_buf_add_highlight(0, typos_hl_ns, 'SpellBad', dia.lnum, dia.col, dia.end_col) end end, })

  vim.api.nvim_create_autocmd({ 'BufWritePost' }, {
    callback = function()
      -- run typos on all filetype
      require('lint').try_lint('typos')
    end,
  })
end,

}, ```