html inside code cell jupyterlab vs google colab - google-colaboratory

google colab can contain code cell content like
##title <font color="orange">**Restart Runtime**</font>
##markdown Click this if `Clean Environment Up` does not work
import os
os.kill(os.getpid(), 9)
It can also contain sliders i've seen in some stable difusion examples.
If I would like to such jupyternotebooks inside my own jupyterlab then what needs to be installed to allow for those html alike rendering of those code cells ?.

Related

How can get ckeditor to paste the image instead of embeding the url

Drupal 9.4.5 (latest)
using module ckeditor upload image 8.x-2.0
installed CKEditor version : 4.18
installed libraries
uploadimage 4.18
uploadwidget 4.18
notificationaggregator 4.18
filetools 4.18
notification 4.18
This is my first attempt to change ckeditor from its defaults so i'm not sure exactly how to attack this problem.
when I right click and copy image on an image in on a web page and then paste it into ckeditor instead of pasting the image it embeds the url I would like it to paste the image instead.
my workaround for this is to paste the image into paint, then copy the image from paint and past it into ckeditor and then it uploads the image. While this does work, it does take more time.
any insight on how I can change this behavior would be really helpful.
this sounds like a ckeditor config question ( hence i a posting here ) but I also posted on the drupal forum to cover my bases.
thanks for your time,
J

Further question on "insert image in Google colab text cell"

I followed the question and answers to question on inserting images into Colab text cells. Similar to that poster, I wish to place images into text cells rather than bring them up using Python code cells.
The source of the images is intended to be files in a subfolder of the project containing the Jupyter notebook whose discussion I want to enrich with photos and drawings. It is important to keep the notebook and supporting files, including images and data, in a single encompassing folder. (I expect to work on dozens of such projects, each with its own assembly of files in separate project folders.)
In order to achieve this I mounted the Google drive containing the image files by running
from google.colab import drive
drive.mount('/content/drive')
I clicked on the file folder in the left sidebar and expanded directories until I could select the image file I want to use and obtain its path. Then I tried using either of the following in a text cell:
<img src="/content/drive/MyDrive/Colab Notebooks/Lab13 Mechanisms/Figures/PantographCloseUp.JPG" alt="Close up of a pantograph made with LEGO Technics and LEGO Mindstorms components">
![Close up of a pantograph made with LEGO Technics and LEGO Mindstorms components](/content/drive/MyDrive/Colab%20Notebooks/Lab13%20Mechanisms/Figures/PantographCloseUp.JPG)
Neither of these work: no image appears. Right clicking on the empty box containing a question mark and choosing inspect element and then the tab "sources", I clicked on the image resource and got "Failed to load resource: the server responded with a states of 403 ()." I understand this is some sort of authorization fault (???).
(The image is set to be shared with anyone with the link.)
What is going on? Why don't the image-in-text-cell methods work using the file paths on the mounted drive? (Ideally, too, I would like to use a relative path: Figures/PantographCloseUp.JPG)
Please note that the following does produce an image in a text cell but is not a terribly convenient way of keeping track of image sources:
<img src='https://drive.google.com/uc?id=1dYjA01xQqah0l2cSQYcd6U0UFrfH3LPK'/>
Also, I can run code to display the image using the desired file path but this is also not convenient because a user (a student) of the document would have to run all of these cells just to look at the pictures.
from IPython.display import Image
Image("/content/drive/MyDrive/Colab Notebooks/Lab13 Mechanisms/Figures/PantographCloseUp.JPG")

TinyMCE 5 - large images pasted via Safari do not render correctly

We are running TinyMCE version 5.4.1 with various options including:
paste_data_images: true
powerpaste_allow_local_image: true
When we drag & drop (or paste) in smaller images (400px X 400px) everything seems to work fine. The Base64 encoding is saved to the database and the image is rendered from all browsers, Chrome, Firefox and Safari.
However, when we paste in a larger image (1920px x 1081px) the image is only saved and rendered correctly in Chrome and Firefox. In Safari the Base64 encoding is saved with all lowercase characters. Therefore it doesn't render when attempting to view it. Has anyone else experienced this?
I have searched here as well as on the TinyMCE website but don't see anything mentioning this behavior. We will eventually attempt to move away from this Base64 implementation as it's no longer recommended but it's what we have for the time being so I'm just trying to address this issue.
When the page loads, its' elements can do so in parallel. But when the browser sees the base64 image, it blocks the page from loading until this image is rendered. Thus, inserting large images into the page as base64 is certainly not a good practice - it may slow down page loads and worsen the UX.
To fix this problem and maybe several other issues, utilizing the automatic_uploads option is highly recommended. It will upload pasted images on the server instead of converting them to base64. Here is the example of the PHP upload handler that will upload images and give their URLs back to TinyMCE.
Concerning the issue with Safari, some minimal reproducible example would be very useful.
I should also mention that PowerPaste is a premium feature that will not work with TinyMCE opensource. If you are using the paid version of TinyMCE, you can create a support ticket.

Xamarin: How do I set a placeholder image in my Image element in XAML?

In Android, it is quite easy to set a image placeholder for development purposes in an imageview.
All one would do is use the tools:src for the placeholder image during development so you could see it in your layout design preview and your actual image you would put into your android:src
. Frequently, you don't set the android:src put would populate that imageview with images that you download off the internet once you connect your app to the net:
<ImageView
android:layout_width="28dp"
android:layout_height="28dp"
android:src=#drawable/activated_icon"
tools:src="#mipmap/white_activated_icon" />
In Xamarin, you have this to display images:
<Image Source="http://lorempixel.com/1920/1080/nature/3" />
Once the app connects, the image is downloaded from the internet and displayed. How do I put in a placeholder image for development purposes (similar to the way you would do it through tools:src in android) so I can see it within the layout design previews?
I'm assuming you want to achieve this with Xamarin Forms, as you referring to XAML in the question title.
Or possibly you are referring to the Xamarin Forms Previewer? In that case, disregard the following answer. You can only use local images in the Previewer as far as I can tell.
Answer in case the question is related to runtime Xamarin Forms
There is no standard option to do this in Xamarin Forms. Take a look at this example suggested by Stephane Delcroix from the Xamarin Forums. The important part of this approach is to stack 2 images on top of each other in a grid. 1 is the placeholder that is placed beneath the image that is being loaded, like this:
var grid = new Grid();
grid.RowDefinitions.Add (new RowDefinition());
grid.Children.Add (image);
grid.Children.Add (placeholderImage);
As an alternative option, WebImage of Xamarin Forms Labs allows an option for a DefaultImage, but I'm not sure if that shows immediately. See this class for the code of the Web Image. Keep in mind that Xamarin Forms Labs is no longer under active maintenance.
Of course you can also write a custom renderer. Maybe based on the Xamarin Forms Labs example.
I use FFImageLoading for this Case.
Just install the Nuget Package and Use the "CachedImage" in XAML.
<ff:CachedImage Source="your url" Placeholder="placeholder while loading"/>
You donĀ“t need to download (and cache) the Image manually then. It will automatically displayed when the download is done.
You can use local files (from Resources or Drawable) and files from HTTP/HTTPS.

Viewing graphs in Jupyter or IPython

I am trying to use both bokeh and matplotlib in my IPython notebook... Neither work perfectly.
Attached is a screen shot of Bokeh. Matplotlib explanation is below.
Here are my system specs:
-Windows 7 with Vagrant
-Jupyter/IPython
BOKEH -- buttons are static images; there is no resizing, yet the graph is interactive
Should look like from this website: http://docs.bokeh.org/en/latest/docs/quickstart.html
MATPLOTLIB -- only static shots appear when it should be zoomable, etc (like bokeh)
1) read the documentation.
you would only change output_file() to a call to output_notebook() instead.
Which you did not seem to do above.
2) Why should it ? What di you do to make it zoomable ?
3) try not to post 2 unrelated question at the same time.
You appear to be using an older version of Bokeh. The issue with the CSS problems (button appearance) has been fixed for some time. As mentioned above, you will need to execute output_notebook() to load Bokeh for IPython notebook usage. For future reference, questions like this greatly benefit from providing as much information as possible (e.g., Bokeh and browser versions, platform information, etc.) Without that information it is impossible to diagnose problems with any certainty.