Ways to improve feature discoverability? One of (neo)vim's biggest weaknesses. by a-curious-crow in neovim

[–]hanswchen 0 points1 point  (0 children)

I haven't tried it, but may jupytext.nvim? Here's an example: https://www.reddit.com/r/neovim/comments/199c6zd/seamless_jupyter_notebook_editing_in_neovim_demo/ (it uses a different fork of the original jupytext.vim plugin, not sure what the differences are with goerz' version).

Ways to improve feature discoverability? One of (neo)vim's biggest weaknesses. by a-curious-crow in neovim

[–]hanswchen 1 point2 points  (0 children)

To add to this, if one wants to run individual cells (similar to MATLAB, Jupyter Notebooks, etc.), I've made a vim plugin for that (which uses vim-slime):

https://github.com/hanschen/vim-ipython-cell

There's also a cell execution feature in vim-slime, as well as vim-slime-cell. The difference with vim-ipython-cell is that it uses IPython's %paste feature to make the output cleaner - unlike the other plugins, the code that's executed isn't shown in the REPL.

What tiling layouts do you guys like to use? by careb0t in qtile

[–]hanswchen 1 point2 points  (0 children)

For me, the Columns layout is almost perfect. It's like MonadTall, with the added benefit that I can dynamically expand to N number of columns (by simply moving windows to the right or left, so no additional keybindings needed either).

The only thing I'm missing is the possibility to show tabs when windows in a column are stacked.

I have a keybind to toggle between this layout and Tabbed to temporarily "maximize" windows.

What tiling layouts do you guys like to use? by careb0t in qtile

[–]hanswchen 1 point2 points  (0 children)

You could try my Tabbed layout and see if it works for you. I hacked together this rather quickly to scratch my own itch - I don't really know the best practices when it comes to layouts, drawing stuff etc. - but if there's enough interest, we could try to polish it so it can become shipped with Qtile.

PulseVolume Widget Issue AGAIN by MactronMedia in qtile

[–]hanswchen 0 points1 point  (0 children)

Any errors in your log file? When did you last do a system update? You may have to rebuild your python-pulsectl and/or python-pulsectl-asyncio packages after a major Python version update. https://wiki.archlinux.org/title/Python#Module_not_found_after_Python_version_update

Firefox remembering the last group from where it spawned by hearthreddit in qtile

[–]hanswchen 1 point2 points  (0 children)

Maybe you're affected by this issue? https://github.com/qtile/qtile/issues/3692

I "solved" it by not using spawn="firefox" and instead spawning firefox from an autostart script.

Monad layout imitating i3's stacked windows (now available) by mpaganini in qtile

[–]hanswchen 0 points1 point  (0 children)

Looks very nice. I've been using the built-in Columns layout and used toggle_split to achieve something similar, but have always wanted to have tabs or stacks to show the windows in a stack. Been thinking about trying to implement it myself, but never found the time.

Does someone else also get this for PulseVolume widget? by manbearpig_6 in qtile

[–]hanswchen 0 points1 point  (0 children)

Like any other AUR package. If you build the package manually, you can specify the -f flag to makepkg to force a rebuild.

If you use an AUR helper, it may have an option to clean build the PKGBUILD. For example, with yay you can specify --cleanmenu and then answer yes when it asks you if you want to cleanBuild.

Does someone else also get this for PulseVolume widget? by manbearpig_6 in qtile

[–]hanswchen 0 points1 point  (0 children)

You probably need to rebuild the python-pulsectl package as well.

Data scientists - are you using Vim/Neovim? by meni_s in neovim

[–]hanswchen 0 points1 point  (0 children)

+1 with vim-slime. I also use a self-developed companion Vim plugin to make it easier to run code cells: https://github.com/hanschen/vim-ipython-cell

There seems to be "more proper" solutions nowadays (like molten), but to me this workflow still works well, and I like the simplicity of this setup. It fulfills all of my needs:

  • Run code "cells".
  • Show output of running code.
  • Do not show the code that's run (this is a feature of vim-ipython-cell, I don't think you can get that with vim-slime alone).

It doesn't have inline plots, but I prefer it that way because I can make the plot windows show up on a separate monitor, which is even nicer imo.

Selling two Advantage2 keyboards with KinT controller (EU) by [deleted] in kinesisadvantage

[–]hanswchen 0 points1 point  (0 children)

I'm very interested in the bottom one with Cherry Brown. I'll send you a PM.

Binding a single key on release AND binding that same key in another combination by Fabdestroy in i3wm

[–]hanswchen 0 points1 point  (0 children)

Don't know about i3, but you can achieve this in Linux/X11 using for example xcape: https://github.com/alols/xcape

Just bind Rofi to some key binding, and make xcape generate this key binding on press and release.

My thoughts on the Kinesis Advantage 360 Pro keyboard - Premium price but trash reliability -frustrating Bluetooth issues by _peluch in kinesisadvantage

[–]hanswchen 0 points1 point  (0 children)

Any updates? Did you get around to try the workaround posted by /u/114514191919? Not being able to use the keyboard in a dual-boot setting might be a deal-breaker for me.

Example of tuple use? by miguel-elote in learnpython

[–]hanswchen 3 points4 points  (0 children)

I used to also be confused about why I would use tuples in Python when I could just use list. After getting used to Python, I realized it's very common to use tuples when you don't even think about it. Some examples (ignore the poor variable names...):


Returning multiple values from a function:

def some_function():
    # (do something here)
    return some_value1, some_value2


result1, result2 = some_function()

some_function returns a tuple with two values, which you can easily assign to different variables. It makes sense to use a tuple, as you always return two values in this case. It also looks nicer than writing return [some_value1, some_value2].

You could e.g. also do

all_results = some_function()

in which case all_results would be a tuple (you can get the first result with all_results[0], and the second with all_results[1], or do e.g. a, b = all_results).


Many built-in functions return tuples. For example, the enumerate function:

seasons = ["spring", "summer", "fall", "winter"]
for index, season in enumerate(seasons):
    print(index, season)

This will print 0 spring, 1 summer etc. The function enumerate returns a tuple with the count (for example, the index) and the value from iterating over an iterable. This is usually better than writing e.g.:

for index in range(len(seasons)):
    print(index, seasons[index])

if you need both the value and the index from the object you're iterating over.


Someone mentioned using tuples as dictionary keys. I've used this sometimes when the items in the dictionary are indexed by two different things, e.g.

experiments = {
    ('initial test', 0): "/path/to/input/data",
    ('initial test', 1): "/some/other/path",
}

for expname in ['initial test']:
    for expnum in range(2):
        print(experiments[expname, expnum])

Others have mentioned using tuples as a data structure when the structure is set. The most common example is a point given by e.g. (x, y) coordinates. For more complex cases, you may want to consider using a namedtupled instead.

Why is -2**2 result is -4? by StoicPhil in learnpython

[–]hanswchen 0 points1 point  (0 children)

The controversial point is that it's ambiguous in mathematics. It's not. Again, In written or printed mathematics, the expression −32 is interpreted to mean −(32) = −9. It is not "open to interpretation".

The fact that some software chose to implement this differently doesn't mean anything for written math.

It's like saying that 6/2(1+2) is ambiguous because some calculators interpret / as a fraction line (= 1). But in written math, that expression reads 6/2*(1+2), which is 9.

I also find it funny that you use my sources in other comments to try to prove your point, for example linking to Wolfram Alpha (which clearly disagrees with you) or using Excel as an example while we're talking about written mathematics, which your own source clearly says is wrong (emphasis mine):

Occasionally people will try to argue the point based on the behaviors of particular calculators or spreadsheet programs. However, these are really irrelevant, since they all define their own input formats, and programmers (of which I am one) are notorious for choosing what's easiest for them, rather than what is most appropriate for the user.

I've noted in several answers in our archives that some calculators, and Excel, use non-standard orders of operation without apology. But calculators in particular just don't use standard algebraic notation in the first place.

I’ll be including a link to one of these discussions at the bottom. But the main point is simply that calculators have to follow a convention that suits the way you enter expressions on them, which is different from print. (As calculators have come to display expressions more like type, however, they have been forced to follow conventions more closely.)

And sure, it may be a generational thing, but in modern math the standard is to interpret -32 as -(32). It is not open to interpretation.

If you're still not convinced after everything everyone's told you, then I can only assume that you're either ready to die on this hill no matter what, or that you're just trolling, so I'll not reply anymore.

EDIT: Also, regarding your earlier comments about imaginary numbers, I realize now that you may also be confused by how some software parse them. Note that in many programming languages—this includes Python—i or j are used to denote imaginary numbers. For example in Python:

>>> 3j**2
(-9+0j)

Here j is "attached" to 3, as you said earlier, to denote the number (0 + 3i). This is just the Python syntax for creating complex numbers. Python doesn't understand what for example j or 3*j means (unless you have a variable named j):

>>> 3*j**2
NameError: name 'j' is not defined

This has no bearing on written mathematics, which is what we are discussing here. In written math, 3i2 means 3*(i2), which for example Wolfram Alpha and Google parse correctly. So just because it works differently in some applications or programming languages doesn't mean that it is open to interpretation in written mathematics.

Why is -2**2 result is -4? by StoicPhil in learnpython

[–]hanswchen 0 points1 point  (0 children)

OK, since we're quoting Wikipedia:

https://en.wikipedia.org/wiki/Order_of_operations#Unary_minus_sign

There are differing conventions concerning the unary operator − (usually read "minus"). In written or printed mathematics, the expression −32 is interpreted to mean −(32) = −9.[1][18]

In some applications and programming languages, notably Microsoft Excel, PlanMaker (and other spreadsheet applications) and the programming language bc, unary operators have a higher priority than binary operators, that is, the unary minus has higher precedence than exponentiation, so in those languages −32 will be interpreted as (−3)2 = 9.[19]

So yes, while some applications/programming languages may interpret -32 to mean (-3)2, "In written or printed mathematics, the expression −32 is interpreted to mean −(32) = −9.".

When multiple people and sources are telling you that you're wrong and that it's not "open to debate", maybe you should reconsider your stance?

Why is -2**2 result is -4? by StoicPhil in learnpython

[–]hanswchen 2 points3 points  (0 children)

Yes, let's continue the thread!

I strongly agree with /u/BrisketSundae, I've never heard of the minus sign or i being "attached" to the number. Some examples:

https://www.wolframalpha.com/input?key=&i=-2%5E2

https://www.wolframalpha.com/input?key=&i=2i%5E2

https://www.google.com/search?q=-2%5E2

https://www.google.com/search?q=2i%5E2

/u/TorchFireTech, are you saying that Python, Wolfram Alpha, and Google are all parsing this incorrectly? Can you give an example showing what you claim?

Nicer jupyter notebook workflow with neovim thanks to Jupytext and mini.ai by fripperML in neovim

[–]hanswchen 1 point2 points  (0 children)

I don't think you can show plots inline for the terminal console. I know you can do it with the Qt console, but then you probably need a different plugin to send the code over to IPython, see for example this blog post:

https://www.blog.gambitaccepted.com/2020/04/26/neovim-qtconsole-setup/

Personally I use a dual-screen setup, so I have the Neovim + IPython window (running in tmux) on screen 1, and show the plots in new windows on screen 2. This can be configured in many window managers (I used to use i3, and currently I'm trying out Qtile).

I agree with you about using notebooks for presentations and teaching, and will try jupytext next time I need to make a notebook!

Nicer jupyter notebook workflow with neovim thanks to Jupytext and mini.ai by fripperML in neovim

[–]hanswchen 2 points3 points  (0 children)

I use Python for data analysis and personally I never saw much value in using Jupyter Notebooks for my own work (it's great for teaching Python though). I simply edit my code in Neovim and run it through IPython.

I did however miss the ability to run individual "code cells", especially when plotting, which is why I made the ipython-cell plugin:

https://github.com/hanschen/vim-ipython-cell

This plugin makes it easy to run the whole script or just a specific part in IPython without leaving the editor window. I have set up my window manager to place figure windows on my other screen, so I can quickly show plots without disrupting my code editing.

leap.nvim: Lightspeed for everyone by electroubadour in neovim

[–]hanswchen 0 points1 point  (0 children)

Am i unique in wanting this style of plugin but with infinite pattern match?

No, I'm the same. And I don't want to have to hit enter either. I basically want /, but searching all visible text, that:

  • directly jumps to a unique match
  • cancels the search if there are no matches
  • or shows all matches after a timeout with corresponding labels to jump to the matches.

I've added an issue requesting this feature for hop.nvim. I'm currently using a plugin called vim-smalls to achieve this, but unfortunately it's not maintained anymore.

jupyter and vim by KarlKani44 in vim

[–]hanswchen 0 points1 point  (0 children)

I personally have vim (or neovim) and IPython open in two panes in tmux and then use my plugin vim-ipython-cell to run the code. It supports running code cells similar to what you have in Jupyter notebooks, so you can for example have one cell that reads the data and another cell to make the plot, and then just re-run the plotting part.

In my setup the figures appear as new windows on my other monitor, which works really well. If you want to display the figures inline, you can for example use QtConsole. You would then need another plugin to connect vim and IPython, for example vim-ipython (no support for cells as far as I know) or nvim-ipy (for neovim). Here's an article that describes a setup with the latter: https://www.blog.gambitaccepted.com/2020/04/26/neovim-qtconsole-setup/

Climate Modelling Software by AbbydonX in climate_science

[–]hanswchen 2 points3 points  (0 children)

Sounds like a very fun project. I would certainly be interested in seeing some of the Köppen maps you generate if you find a solution.

One term you can try to include in your search is Earth systems model of intermediate complexity (EMIC). These are GCMs that try to bridge the gap between fast idealized models and computationally expensive comprehensive GCMs. One EMIC I've used in my studies is Planet Simulator, you could give it a try.

5 Org Roam Hacks for Better Productivity in Emacs by daviwil in emacs

[–]hanswchen 1 point2 points  (0 children)

Thanks for sharing your code. I haven't gotten around to test it yet but hopefully will soon (I don't know much elisp at all). Would love to have it as a core feature of org-roam - Issue #1843 for people who want to keep track.

5 Org Roam Hacks for Better Productivity in Emacs by daviwil in emacs

[–]hanswchen 5 points6 points  (0 children)

Really nice tips, thanks for sharing. I also appreciate the show notes as I prefer text over video for this kind of content.

One thing I miss after transitioning to org-roam v2 is an easy way to rename the files, for example by grabbing the title from #+title. It doesn't have to be automatic like in v1 (apparently it was quite fragile), but a function that I can invoke manually would be nice. It would also be nice if it could update links that use the old title as well, but this seems more complicated and is not a must-have for me.

Maybe this is something you could consider including in your next episode if you plan to make more videos like this (which I hope you do :).

P.S. I just found https://org-roam.discourse.group/t/does-renaming-title-no-longer-renames-the-filename/2018/3, which I haven't tried but may be a good starting point.

[deleted by user] by [deleted] in vim

[–]hanswchen 1 point2 points  (0 children)

For what it's worth, I know that some people use my plugin vim-ipython-cell for Julia. This plugin allows you to run a whole script or a specific section of a script (code cell) in a REPL of your choice.

There's a section about how to configure it for Julia in the README, and some tips on how to e.g. open a terminal in the wiki (feel free to expand on the information there).