It is possible, generally, by means of Ruby library to output a symbol at specific location on a common Windows console screen, which seems to be 80x25 ?
The problem came up with the need to draw a specific 'tree' structure like this, for example:
│
├──x──y──z
│ │
│ ├──a──b──c
│ │
│ └──e──f──g
│
└──u──v──o
If you're just interested generating trees in the console, this post shows you how to do it with hirb.
You could use a wrapper for Curses, like this one.
The Win32Console project should do what you want, and much more. Also, your question reminds me slightly of Ruby Quiz #14 (LCD Numbers).
Related
My question is since Octave sometimes outputs in symbolic like
s a
--- - ---
4 4
I just want it to show like
s/4-a/4
so I can copy and paste it for other scripts.
I am sure this is simple but could not find anywhere both in documentation and site.
Thank you very much for your help
Essentially you want is
sympref display flat
Have a look at the documentation here for more info:
https://octave.sourceforge.io/symbolic/function/sympref.html (look at the display section)
https://octave.sourceforge.io/symbolic/function/#sym/pretty.html
Currently I do this:
conf.py:
autosummary_generate = True
reference.rst:
package_1
---------
.. autosummary::
:toctree: _generated
package_1.module_1
package_1.module_2
package_1.module_3
...
This will generate an overview table for each module, with entries for each module
that nicely link to detail pages.
I have two questions:
Do I really have to enumerate every single module?
How can I control the options of the detail pages?
Ad 1.:
I would like to do s.th like this (which currently doesn't work):
.. autosummary:: package_1
:toctree: _generated
:members:
(Or maybe a new autopackage command.)
Ad 2.:
I would like to pass options like the ones that automodule or autoclass expect, e.g.:
.. autosummary::
:toctree: _generated
:undoc-members:
:private-members:
This seems to be an obvious task, so I am probably missing some information.
Is there an easy alternative way to accomplish this?
Thanks to all commenters!
Ad 1:
I list the modules manually.
Ad 2:
I finally went with the solution proposed by this and this answers to similar questions:
Create template files (_templates/autosummary/module.rst and _templates/autosummary/class.rst) and add this to
api_doc.rst:
Package ``wsgidav``
-------------------
.. autosummary::
:toctree: _autosummary
wsgidav._version
wsgidav.compat
I typically put the high-level documentation for a Python package into the docstring of its __init__.py file. This makes sense to me, given that the __init__.py file represents the package's interface with the outside world. (And, really, where else would you put it?)
So, I was really quite surprised when I fired up Sphinx for the first time and saw this content buried near the very end of the package documentation, after the content for all of the submodules.
This seems backward to me. The very first thing the user will see when he visits the page for a package is the documentation of the submodule that just happens to come first alphabetically, and the thing he should see first is right near the bottom.
I wonder if there is a way to fix this, to make the stuff inside of __init__.py come out first, before all of the stuff in the submodules. And if I am just going about this in the wrong way, I want to know that. Thanks!
Updated Answer (thank you, Donal Fellows):
https://www.sphinx-doc.org/en/master/man/sphinx-apidoc.html#cmdoption-sphinx-apidoc-M
Original Answer:
Yes, there is an option to do this, it's just not documented here. Inside my copy of Sphinx-1.3.3/sphinx/apidoc.py I found this:
parser.add_option('-M', '--module-first', action='store_true',
dest='modulefirst',
help='Put module documentation before submodule '
'documentation')
I tried it and it works like a charm.
It is also possible to add this option in the conf.py file.
Search in conf.py for the line where the string containing the sphinx-apidoc command is (located in a try section) and add the "--module-first" option.
The new line will look like this:
cmd_line_template = "sphinx-apidoc --module-first -f -o {outputdir} {moduledir}"
Hadn't used Sphinx in a while, but it does seem like they've done a good job updating it. In the past, I had to manually specify the classes since I didn't like how autodoc generated the methods/functions. Now it does seem like you can order them:
.. autoclass:: YourClass
:members: __init__, __getitem__
http://www.sphinx-doc.org/en/stable/ext/autodoc.html
I am writing a program in C++ that requires IP addresses( all IPv4) to be looked up and stored in a fast way. Every IP address has a data associated with it. In case it already exists in the trie, I intend to merge the data of the IP address in the trie with the new addresses data. If it is not present, I intend to add it as a new entry to the trie. Deletion of IP address is not necessary.
In order to implement this, I need to design a Patricia Trie. However, I am unable to visualize the design beyond this. It seems quite naive of me, but the only idea that came to my mind was to change the IP address to their binary form and then use the trie. I am however clueless about HOW exactly to implement this.
I would be really thankful to you if you could help me with this one.
Please note that I did find a similar question here . The question or more specifically the answer was beyond my understanding as the code in the CPAN web site was not clear enough for me.
Also note, my data is the following format
10.10.100.1: "Tom","Jack","Smith"
192.168.12.12: "Jones","Liz"
12.124.2.1: "Jimmy","George"
10.10.100.1: "Mike","Harry","Jennifer"
I think you are referring to a RadixTree. I have an implementation of a RadixTrie in Java, if you want to use that as a starting point, which does the actual key to value mapping. It uses a PatriciaTrie as it's backing structure.
Example using the following strings.
10.10.101.2
10.10.100.1
10.10.110.3
Trie example (uncompressed)
└── 1
└── 0
└── .
└── 1
└── 0
└── .
└── 1
├── 0
│ ├── 1
│ │ └── .
│ │ └── (2) 10.10.101.2
│ └── 0
│ └── .
│ └── (1) 10.10.100.1
└── 1
└── 0
└── .
└── (3) 10.10.110.3
Patricia Trie (compressed)
└── [black] 10.10.1
├── [black] 0
│ ├── [white] (0.1) 00.1
│ └── [white] (1.2) 01.2
└── [white] (10.3) 10.10.110.3
Patricia tries solve the problem of finding the best covering prefix for a given IP address (they are used by routers to quickly determine that 192.168.0.0/16 is the best choice for 192.168.14.63, for example). If you are just trying to match IP addresses exactly, a hash table is a better choice.
Is there a built-in way to determine if an asset exists without resorting to File.exists?(File.join(Rails.root, "foo", "bar", "baz")) and that looks through the asset paths.
My app goes and fetches images from a remote server on a Resque queue; until we have the image downloaded I want to serve a placeholder image. Currently I'm using File.exists... but this means hard-coding a path, which sucks, or looking through the configured asset paths. It seems like this should be there already, but I can't find it in the docs.
Given an image in app/assets/images/lolshirts/theme/bg-header.png,
Rails.application.assets.find_asset 'lolshirts/theme/bg-header.png'
=> #> Sprockets::StaticAsset:0x80c388ec pathname="/Users/joevandyk/projects/tanga/sites/lolshirts/app/assets/images/lolshirts/theme/bg-header.png", mtime=2011-10-07 12:34:48 -0700, digest="a63cc84aca38e2172ae25de3d837c71a">
Rails.application.assets.find_asset 'notthere.png'
=> nil
Since this is still the top question when searching Google, and since the accepted answer does not work properly in production (at least in some cases), here is the solution that works for me (Rails 4.x to 6.x at least):
def asset_exist?(path)
if Rails.configuration.assets.compile
Rails.application.precompiled_assets.include? path
else
Rails.application.assets_manifest.assets[path].present?
end
end
This is copied from this github issue
See this answer:
https://stackoverflow.com/a/8217598/549252
= Rails.application.assets.find_asset("my_asset.css").nil?
Please see the answer here for a discussion on why find_asset may not always work:
Include Assets Only If They Exist