How to create a swift notebook on google colab - swift

I have seen some nice demo on the dev summit on Swift for Tensorflow. So would like to try this out.
I could open this notebook:
https://github.com/tensorflow/swift/blob/master/docs/site/tutorials/custom_differentiation.ipynb
and if you view the nb runtime setting, the runtime type dropdown indicated "Swift".
However, I can't find anywhere in the colab menu how you can create a notebook thats swift from scratch.

Presently, the simplest way is to create a copy of an existing swift notebook. Use the menu item File -> Save a copy in Drive...

For those who want to do hack, or just upload a blank notebook thats configured to run Swift once it gets to Colab, here's maybe useful json snippets:
{"nbformat":4,"nbformat_minor":0,"metadata":{"colab":{"name":"Blank for Swift.ipynb","version":"0.3.2","provenance":[{"file_id":"https://github.com/tensorflow/swift/blob/master/docs/site/tutorials/custom_differentiation.ipynb","timestamp":1552503857805}],"collapsed_sections":[]},"kernelspec":{"name":"swift","display_name":"Swift"},"accelerator":"GPU"},"cells":[{"metadata":{"id":"iROrFnecc1gX","colab_type":"code","colab":{}},"cell_type":"code","source":[""],"execution_count":0,"outputs":[]}]}

Related

How to show a tutorial for vscode extension?

I am building an extension for VsCode and wanted to show a small tutorial on how to use it, but I can't find an appropriate API for that. Obviously, I can save some variables in the global state to follow user progress and use some FE framework to do some drawing in a webview, but it feels very custom. I saw that VSCode shows a tutorial on initial installation and hoped I can do the same.
In VSCode it is called a walkthrough and is defined simply in package.json. Here is a link to this API: https://code.visualstudio.com/api/references/contribution-points#contributes.walkthroughs
and this an example project https://github.com/microsoft/vscode-extension-samples/blob/main/getting-started-sample/package.json#L39
It is pretty easy to define and use. It accepts text, media files, and markdown files.

Adding the run-code option to a new language in VSCode

I'm currently writing my own language and I'm at a point where I would like to publish it to the VSCode-Marketplace so people can test it.
I have written a language extension and a syntax highlighter with the Yeoman-Generator and now want to merge it with my executable file that launches the interpreter, so that a file can get interpreted after clicking the run-code button.
I now have checked multiple articles, like:
How to add a run button in visual studio code? - StackOverflow
How to define or support a code language on Visual Studio? - StackOverflow
Debugger Extension Guide - VSCode API
However, I haven't found anything useful.
Currently, the code-runner displays the following error, when clicking on run, or pressing the shortcut:
(Code language not supported or defined.)
But even after a lot of browsing Google for adding new language support to the code-runner, I found absolutely nothing helpful.
(See this page, idk what Settings/Preferences they are referring to!?)
I also was not successful with tasks, as they don't seem to connect to the run-buttom or debug-button in any way.
My question is: How can I make the run-button execute a custom bash-command, when a file in my language is opened?
Okay, I finally did it.
For anyone wondering:
You have to go to the settings and type "code-runner" into the search bar.
Scroll down a little, and you should find the code runner-executor map.
Click on the "edit in settings.json" button.
Now a .json-file should've opened. There are two possible scenarios: Either, there is a json-object called code-runner.executorMapBy... or not.
If there is none, type code-runner.executorMapByFileExtension and let autocomplete do the job.
If the json-object exists, add the file-extension and a bash command that executes your compiler/interpreter. It gets automatically executed in the directory the program-file lies in.
Now still dont know, how to include the settings in my extension, but that was already a big step. Further help is still appreciated!
There is an open source extension called code runner, you can check source code there.

How to open a Flutter .hive file from Hive in Android Studio

Can someone please explain how to open the .hive files generated by Flutter Hive when you create a Box and add to it?
Within my application, the files are stored as name.hive files.
I have tried opening them as JSON/XML/plain text but nothing seems to work, the contents are showing incorrectly
I am using Android Studio on Ubuntu
Just want to know how I can open the file and view the contents properly?
An issue was opened for this and the answer is:
Hive uses a custom binary format for storing data which isn't supported by any existing editors or tools.
so you cannot actually open a box .hive file like you could do with JSON, XML...
The easier way would be to copy .hive file to your computer and drag it into Hive Studio window.
I wrote an app and a tutorial using Hive DB, where I describe this.

Cannot change content of an Edit control

I am using pywinauto to open a file in some software. My code is supposed to open a specific file using the Open dialog:
import pywinauto
from pywinauto.application import Application
app = Application(backend="uia").start(cmd_line="C:\\Program Files (x86)\... etc")
app.Dialog.Close.click()
app.FORAM3.Derivative.OpenSpectrum.click()
app.FORAM3.Open.Edit.SetEditText(r"C:\\Users\... etc")
The code opens the software and clicks the "Open Spectrum" button, where it gets the standard Open dialog:
on the line app.FORAM3.Open.Edit.SetEditText("Paracetamol 4.foram") I get a pywinauto.findwindows.ElementNotFoundError which states that it could not find an element or a method called SetEditText.
I have already looked around on the internet and cannot find any solutions.
How to open an existing file using pywinauto from SourceForge says to use app.Open.Edit.SetEditText.
I tried using app.Open.Edit, removing the "FORAM3" part, and it could not find "Open".
I replaced this with app.Dialog.Edit and it gave me the original ElementNotFoundError.
I also looked at Open an existing excel workbook using pywinauto, however the answer to this question suggests opening the file within excel itself, which does not apply to me.
I even tried replacing SetEditText with TypeKeys and got AttributeError: Neither GUI element (wrapper) nor wrapper method 'TypeKeys' were found (typo?)
One answer in another question, "Open file from windows file dialog with python automatically", suggests to use pywinauto and gives the following code:
from pywinauto import application
app = application.Application().start_('notepad.exe')
app.Notepad.MenuSelect('File->Open')
# app.[window title].[control name]...
app.Open.Edit.SetText('filename.txt')
app.Open.Open.Click()
I tried again using SetText and again got the AttributeError saying that it could not find an element or method with that name.
The accepted answer for this particular question says to use ctypes. I may resort to this if I cannot find a solution in pywinauto. The question has also been suggested as a possible duplicate of Choosing a file in Python with simple Dialog so I looked at that.
The accepted answer here suggests to use Tkinter. The other two suggest easygui and Zenity. Not what I'm after. There are no mentions of pywinauto in the other answers.
I am not asking how to open a file. From the answers I've looked at I can clearly see how to do it. My question is: Why isn't it working? It's clear that my code isn't recognising any of these Methods that have been suggested, so there must be something else wrong.
I started using Inspect.exe.
Part of the hierarchy has a Pane with an empty string for a name. This could be the problem, however I've worked on other software with empty panes in. In those cases I have been able to ignore the empty panes and still use the child controls. There are also three different controls with the name "Filename" which could be an issue, however since I have referred to the Edit control, it can only be one of them. I did a quick check to see whether I had to refer to the Edit control as a child of the combo box, used the line app.Dialog.combobox.Edit.SetText, and got the same AttributeError again.
My final attempt at fixing the problem was to try a different console. I have been running my code in PyCharm and found a question on jetbrains asking if it was possible to run code from PyCharm in an external console, stating that the PyCharm console did not have the same low-level control that the windows cmd.exe has.
I ran my code in the IDLE shell, and got the same error:
I tried running the code in the regular python command prompt, and it closes with the same error. This seems enough evidence to suggest that PyCharm itself isn't the issue here.
So, to reiterate: Why doesn't python recognise any Edit control methods?
backend="uia" provides different hierarchy and different method names (sometimes). Default backend is "win32" so old Notepad examples are not always relevant for "uia" backend. Also old CamelCase methods are deprecated in 0.6.5 and they even exist in "win32" backend only. Use PEP-8 method names for "uia" backend like set_text. And upgrade by pip install -U pywinauto.

how to show all methods that i can choose in ipython notebook?

I'm new to ipython notebook. When typing a code line, it should show all methods or attributes that I can choose. However, it didn't, and I'm not sure why.
It should look like this:
Does anyone know how I can get this to work?
Type the library name
Type period symbol .
Press tab
At this point you will see drop down menu (showing all the methods)
This works for both python 2 and python 3
That should be a new feature of IPython 6.0.
But as mentioned in the official release post, is still just for command line users, and they are working to port it to all other users.