I'm using jupyter-vim-binding. I can toggle line numbers with C-o, Shift-L. How can I enable line number upon start-up (i.e. when creating a new code cell)? I'm aware of the customization js file but I'm afraid of breaking the current setup, so would like answers from more seasoned users.
The Jupyter Notebook docs show an example to change the default indentation of code cells. You can follow the instructions on that page, but instead pass the lineNumbers argument:
var cell = Jupyter.notebook.get_selected_cell();
var config = cell.config;
var patch = {
CodeCell:{
cm_config:{lineNumbers:true}
}
}
config.update(patch)
You should still be able to toggle line-numbers with the jupyter-vim-binding shortcut.
Related
I'm currently trying to develop an Anki addon that changes the note type of a card when in the card browser.
To accomplish this, I'm initially hooking into the editor shortcuts via aqt.gui_hooks.editor_did_init_shortcuts.append(), then adding a shortcut that sends a callback to another function, passing in aqt.editor.Editor into a function
the problem is I'm now having a hard time changing the note type of the card.
I've tried editor.note.note_type = mw.col.models.by_name(note_type), but it doesn't seem to change anything.
I've looked at other anki extensions, but it seems they change the note_type by modifying the notetype_chooser.selected_note_type_id field of aqt.addcards, which is not found in aqt.editor.Editor
here's the code I have so far:
def editor_switch_note_card_type(editor: aqt.editor.Editor, note_type: str):
# doesn't do anything
editor.note.note_type = mw.col.models.by_name(note_type)
# does something
editor.note['Front'] += 'hello world'
# not sure if this does anything
mw.col.update_note(editor.note)
# editor_init_shortcuts binds editor_switch_note_card_type to a shortcut key when editor is focused
aqt.gui_hooks.editor_did_init_shortcuts.append(editor_init_shortcuts)
I'm making a simple Node JS app.
It logs a lots of informations on console. I would like to know if it's possible to add a horizontal lines in Node JS command line without using any extra packages or dependencies.
If command prompt supports HTML elements, then I could use something like console.log("<hr>"); for adding a horizontal line but it does not support HTML.
Is there any way ?
To create the string for the horizontal line:
const line = '-'.repeat(process.stdout.columns)
.repeat() method repeats the string.
process.stdout.columns returns the number of columns.
To use it:
console.log(line)
The console does not support rendering HTML elements.
That does not prevent you from making a custom line however!
const lineBreak = '----------------------'
console.log(lineBreak)
Of course, customize the linebreak however you'd like:
______ //Underscores!
----- //Hyphens!
====== //Equals!
For grouping related data, refer to the docs here: console reference
Example:
function name(obj) {
console.group('name');
console.log('first: ', obj.first);
console.log('middle: ', obj.middle);
console.log('last: ', obj.last);
console.groupEnd();
}
name({"first":"Wile","middle":"E","last":"Coyote"});
Will output grouped data to the console, visually giving it a line break & arrow to collapse the group. I think this would work well for your use case.
Working off on the same vane as #sergey above:
If your output has a header of a determinable length you can use the .length method.
const header="This is my header";
console.log(header);
console.log('-'.repeat(header.length);
I am trying to write Markdown (for wiki) in GitLab editor with bullet list, with the possibility that the bullet list contains multi-line code.
I tried with this code:
- Test
```javascript
var somecode = 5;
somecode++;
```
- Another line
but this gives me strange results:
If I add an additional empty line between - and ```:
- Test
```javascript
var somecode = 5;
somecode++;
```
- Another line
I get better results, but the code is not aligned with the bullet list:
Here are the expected results:
How can I achieve the upper design? (Code has margin on the right to align with the bullet list content.)
You should use an empty line and four spaces before the multi-line code:
- Test
```javascript
var somecode = 5;
somecode++;
```
- Another line
Result:
Perhaps the behaviour changed with recent Gitlab releases (the Markdown processor changed in version 11.1 on July 22, 2018) since #tamás-sengel answer does not work with (at least) Gitlab 13.0.5.
You should simply align the code block with the first letter of the text using as many spaces as required. No new line is necessary between the text and the code block.
For example, the following markdown :
As of this day, the following actions are available :
- Building libraries (with automated tests) :
```bash
DOCKERFILE_TARGET="build-libs" docker-compose build
--pull
--no-cache
libs
```
- Building the application (with automated tests) :
renders as :
from pywinauto.application import Application
app = Application().Start(cmd_line=u'"path to program" ')
afx = app[u'Afx:01360000:0']
afx.Wait('ready')
afxtoolbar = afx[u'1']
toolbar_button = afxtoolbar.Button(3)
toolbar_button.Click()
window = app.Dialog
window.Wait('ready')
edit = window.Edit4
edit.Click()
app.typekeys ("Success")
So at this point, I've gotten the application to open, the correct window to pop up and also a mouse click on the box that I want to populate with a short string. I cannot for the life of me, figure out how to pass keyboard input to this field. I have read all the docs for PyWinAuto, and nothing is helping...
Basically all I need to do is figure out how to send a string, and then how to send the TAB key six times. I can then finish my program to automate this application.
I am also using Swapy64bit to help. The program uses a win32 backend. I'm using Python 3.6.
Am I not prefixing typekeys correctly? The PyWinAuto documentation leaves much to be desired.
First the correct name of the method is type_keys, but assume you use it correctly.
The reason might be losing focus at the edit control because type_keys tries to set focus automatically. The solution is:
app.type_keys("Success{TAB 6}", set_foreground=True)
I'd like to apply a command line override to an ovm_sequence object like this:
+ovm_set_config_int=*,max_timeout,100000
The max_timeout field is declared inside ovm_sequence_utils macro.
Is there any way to do it? My understanding is that ovm sequences are not part of the ovm hierarchy, so perhaps they can't be modified from the command line.
I'm not aware of a mechanism that lets you set-up config space like that from the command line. A quick grep of the OVM source doesn't show anything either.
A quick comment on
ovm sequences are not part of the ovm hierarchy
They're not constructed at build time, that's correct. They are created just before they start running on a sequencer, but any ovm_object based class can interrogate a config integer via get_config_int()
Normally I'd use a plus-arg for things like this, and the set the config int in my base test class based on that plus-arg. For example, the command line would have:
+max_timeout=100000
...and then, in my base test class, which all my tests inherit from:
function void build();
int timeout;
[....]
if ($value$plusargs("max_timeout=%d", timeout)) begin
`ovm_info(get_type_name(), "Setting timeout", OVM_MEDIUM);
set_config_int("*", "max_timeout", timeout");
end
[....]
endfunction
Normally my uses are not quite so literal as that, having flags that set multiple values up, but that's the basics of it.
I got it working (following instructions from http://www.testbench.in/OT_10_OVM_SEQUENCE_5.html) by adding the following to my ovm_sequence in task body():
if(!(p_sequencer.get_config_int("max_timeout",max_timeout)))
max_timeout = ... // some default value
The key here is that the command line config needs to be set for the sequencer, and the sequence can pick up that config using the above-mentioned code.