Ipython notebook on 2 columns - css

I'd like to have to have cells of a python notebook on 2 columns, for writng annotations next to code (for example, instead of inserting 2 cells below, I would insert I insert a cell on the right and a cell below on the left)
I know that it's possible to use custom css for changing the appearance (e.g https://github.com/nsonnad/base16-ipython-notebook/blob/master/ipython-3/output/base16-3024-dark.css ), is it possible also for the layout?
On the other hand, I found an example of how to use the css for creating a table layout (https://pixelsvsbytes.com/2012/02/this-css-layout-grid-is-no-holy-grail/), but not being very familiar with CSS I don't understand if this can be applied to an unknown number of equal blocks (unknown because they are generated interactively by the user). For reference, here is how currrently looks like:

You could just change the cells to markdown or raw and make them float right.
from IPython.core.display import HTML
HTML("<style> div.code_cell{width: 75%;float: left;}"
+"div.text_cell{width: 25%;float: right;}"
+"div.text_cell div.prompt {display: none;}</style>")
Now when you enter a cell and want it on the right press esc-r (or m).
esc- unselects it and allows the notebook to process commands. r is the command to make a raw cell.

Related

Create new emphasis command R Markdown

In R Markdown, to make a text bold, we just need to do:
**code**
The the word code shows in bold.
I was wondering if there is a way to create a new command, let's say:
***code***
That would make the text highlighted?
Thanks!
It is not easily possible to create new markup, but one can change the way existing markup commands are rendered. Text enclosed by three stars is interpreted as emphasized strong emphasis. So one has to change that interpretation and change it to something else. One way to do so is via pandoc Lua filters. We just have to match on pandoc's internal representation of emphasized strong text and convert it to whatever we want:
function Strong (strong)
-- if this contains only one element, and if that element
-- is emphasized text, convert it to highlighted text.
local element = #strong.content == 1 and strong.content[1]
if element and element.t == 'Emph' then
table.insert(element.content, 1, pandoc.RawInline('html', '<mark>'))
table.insert(element.content, pandoc.RawInline('html', '</mark>'))
return element.content
end
end
The above works for HTML output. One would have to define what "highlighted text" means for each targeted format.
See this and this question for other approaches to the problem, and for details of how to use the filter with R Markdown.

How to customize the look of currently selected(highlighted) completion in zsh?

Main question
I would like to add powerline characters at the start and at the end of the selected completion, like this:
Started the completion menu by inserting c and pressing the TAB key.
Moved right in the completion menu by pressing the right arrow key.
Moved down in the completion menu by pressing the down arrow key.
Is there any way to make zsh look/behave like in the pictures?
Note
Added powerline triangle + blank character at the beginning and blank character + powerline triangle at the end should somehow be accounted when columns are created to keep the alignment correct.
Bonus
Add 2 blanks at the beginning of every completion in the list, so that when the completion is selected it doesn't look like the text was moved to the right.
( This issue can be seen by comparing the completion with and without the selection. )
Alternative question
In case that previously explained behavior is impossible to get without changing the zsh source code, is it at least possible to add powerline triangle only at the end of the selected completion?
My unsuccessful attempts
I have tried using the lc, rc, and ec variables in the list-colors style but that didn't help:
Completion list was badly aligned and it created all kinds of visual problems.
Symbols were inserted in all elements of the completion list, not just the selected one.
I have also tried using the ma variable, but I couldn't properly insert a character at the beginning:
The variable expects only a number that represents a color and it is probably wrapped in some escape sequences, so the output did not look as expected.
This works for me.
zstyle ":completion:*:default" list-colors ${(s.:.)LS_COLORS} "ma=48;5;153;1"
Uses my LS_COLORS and then ma sets the background of my selection to bold and color 153 from https://jonasjacek.github.io/colors/.
Found from https://www.zsh.org/mla/users/2010/msg00811.html

Define global variables

I'm trying to test some algorithms in LibreOffice Calc and I would like to have some global variables visible in all cell/sheets. I searched the Internet and all the posts I have seen are so cryptic and verbose!
What are some simple instructions of how can I do that?
Go to Sheet → Named Ranges and Expressions → Define. Set name to "MyVar1" and expression to 5. Or for strings, use quotes as in "foo". Then press Add.
Now enter =MyVar1 * 2 in a cell.
One strategy is to save the global variables you need on a sheet:
Select the cell you want to reference in a calculation and type a variable name into the 'Name Box' in the top left where it normally says the Cell Column Row.
Elsewhere in your project you can reference the variable name from the previous step:
Using user-defined functions should be the most flexible solution to define constants. In the following, I assume the current Calc spreadsheet file is named test1.ods. Replace it with the real file name in the following steps:
In Calc, open menu Tools → Macros → Organize Macros → LibreOffice Basic:
At the left, select the current document test1.ods, and click New...:
Click OK (Module1 is OK).
Now, the Basic IDE should appear:
Below End Sub, enter the following BASIC code:
Function Var1()
Var1 = "foo"
End Function
Function Var2()
Var2 = 42
End Function
The IDE should look as follows:
[![Enter image description here][5]][5]
Hit Ctrl + S to save.
This way, you've defined two global constants (to be precise: two custom functions that return a constant value). Now, we will use them in your spreadsheet. Switch to the LibreOffice Calc's main window with file test1.ods, select an empty cell, and enter the following formula:
=Var1()
LibreOffice will display the return value of your custom Var1() formula, a simple string. If your constant is a number, you can use it for calculations. Select another empty cell, and enter:
=Var2() * 2
LibreOffice will display the result 84.

ipython notebook rearrange command history order

I am working on a demo notebook. While working on it I am inserting commands and sometimes going back at a previous cell to insert more commands. At the end, I want the command numbering to be increasing order, not the random order I entered them while preparing the notebook.
Any way to conveniently do this from the notebook? I can go and edit the .ipynb file associated with the notebook and edit the "prompt_number" fields to make the command ordering as I want, but a more convenient way is better.
Based on no responses, I am posting the editing of the underlying .ipynb file as the answer to rearrange numbering.
When you edit the ipynb file, note that most of the time the numbers are paired (output and input):
"output_type": "pyout",
"prompt_number": 35,
"text": [
"Empty DataFrame\n",
"Columns: [utilization]\n",
"Index: []"
]
}
],
"prompt_number": 35
},
vim tip: I did a /prompt_n/b+16 search on vim which takes you to the beginning of the number, then just doing cw to the new number you want works. For the second number of the pair, just do .
Note: Be careful about the paired numbers, I found the first one is the output one and ends with a comma. The second one is the input one without a comma. But if you have intentionally deleted a particular in/out cell from the web interface, the pair may be missing so be careful to put same new number to same in/out pair, and not give same number to different in/out cells, which will garble the notebook and web interface will complain about errors.

Lyx: How to make multiple lines on the lowertitleback (koma-script)

I am trying to use uppertitleback and lowertitleback in lyx (2.0.0)
If I just use uppertitleback and lowertitleback with one line apiece, it works just as expected.
However, if I put any text in between the uppertitleback and lowertitleback, then the entire lowertitleback ends up on the top of the next page.
What I want is the following in lowertitle back:
Copyright Statement
ISBN number
Any suggestions??? (I tried changing my page size back to default, but that didn't make a difference.)
Thank you before I pull out more of my hair!!
It turns out that you need to insert a line break (I used a ragged line break) between each line so it passes it to LaTeX as all one paragraph. Arrrrggghhhh!

Resources