Is there a way of passing a short string to a Google Colaboratory webapp notebook instance? - google-colaboratory

I'm experimenting with Google Colab as a mobile tool for pulling data from a public repository, using the webapp running on my phone.
I'd like to use this when I'm on the go, but one of the inputs I need is the lat-long of my current location.
Ideally I'd like to take the url that would open the colab notebook by itself and add a query parameter like so:
http://colab.research.google.com/drive/<somenotebook>?arbitrarykey=arbitraryvalue
and then, in the notebook, use a method like
val = env.readVar('arbitrarykey')
to read it back, as it is easy for me to build and then open such a url.
Is there any such functionality or method for doing this?
PS My fallback is to write a one-off Android app, read my current location, dump it on the clipboard, and then manually paste that in some code block in my notebook assigning it to a variable. Works, but not as elegant.

Related

Bulk text2speech Generation with R

Is it possible to loop through a list of words in R that can each be generated into separate “speech” files using the speech2text website?
https://www.text2speech.org/
To make one file manually one has to type in the text one one page then submit it. A second page then opens with the option to download the file. Since I want to do many of these I would like to find a way to automate it. I have no idea how to approach this idea though.
EDIT
So I am using "say" on mac based on a the helpful comments. I am running it through R using a loop for all strings in a vector
for(i in 1:nrow(test[1:5])){
system("say", intern =F,input = test$English[i])%>%saveRDS(paste0("/Users/Desktop/tts/", test$English[i],".aiff"))
}
This creates the files as expected in the expected location but the .aiff files won't play in any media player. Does anyone see what I am doing wrong?
Consider using a CLI based solution for TTS, like espeak/espeak-ng (cross-platform), festival (linux), say (osx) or via powershell on windows (here's a script). Looks like the page you're referencing is using flite, which is a lightweight (and downloadable) version of festival.

Accessing localhost with data sent from game (War Thunder)

While playing the game War Thunder if you use the address http://localhost:8111 you can access a website that shows the current parameters of your plane that you are flying.
I want to access this data and automatically export it into files. For example the power performance of the engine at certain heights.
I use beautiful soup and urllib to access the data. However I have no clue how to send the data from my game with it. Without that however the website does not show any data.
Does anyone have an idea how I can send this data with my request?
If you're writing your script in Python, you can use this module. Once you have the data, you can write out the data like so:
with open('logger.txt','a') as outFile:
outFile.writelines(data)
Obviously, it'll take more effort to get things working, but it's a good start.

How to get current account name in google colab

For example, if my current Colab instance is signed in as
myColab#gmail.com
Is it possible to get the name "myColab" in ipython?
What is the command to do this?
I want to do this because I may run two Colab, and they generate files, I want to tag these files with Colab account name, so I know which account generate these files.
By default, the backends are not authenticated for any particular user. But, if you've gone through through the gcloud auth flow, you can retrieve the email address like so:
https://colab.research.google.com/drive/1VVWs_pcjjz2vg0H2Ti6-12FzcCojRF6a
The key snippet is:
import requests
gcloud_token = !gcloud auth print-access-token
gcloud_tokeninfo = requests.get('https://www.googleapis.com/oauth2/v3/tokeninfo?access_token=' + gcloud_token[0]).json()
print(gcloud_tokeninfo['email'])
Or just run following:
!gcloud config get-value account
I was trying to get the current user logged in via the GDrive authenticaiton. I do not wish to push another authentication, just to record the name. I believe OP was attempting the same thing.
My theory was, login with google drive, create a file, then read the file's creator. This does not function as intended, it only returns root:root. But it might spark an idea how to make this work in someone who knows more about python and colab then me.
If you create the file in the directory MyDrive, GDrive can see the file and it says owner is Me, hovering over me shows the email account. GDrive knows who made it. I can just not figure out how to make colab output the real file owner, even for files already existing in MyDrive. I assume it is something to do with the mount being symbolic, but.. there HAS to be a way.
Code
print("test", file=open("owner.txt", "a"))
from pathlib import Path
path = Path("owner.txt")
owner = path.owner()
group = path.group()
print(f"{path.name} is owned by {owner}:{group}")
Output
owner.txt is owned by root:root

XPages POI4Xpages download to network location

Using POI4Xpages which is great LINK
However, I was wondering, at present, when it creates my word document, it simply downloads, like a normal download from the internet, storing it the downloads folder in windows (using Chrome anyways)
Is there a way, using POI4XPages, to instead, dump the file to a specified network location, for example a shared drive?
After that, I would simply build a link to the file using the network location, and a filename variable for example to pick the correct file.
If thats not possible, is it possible to get a handle on the file before or after it is downloaded, and then save it to a field in the xpage?
In short, I want to avoid the user downloading the file, then having to attach it manually to the xpage.
Thanks
POI allows you to get a handle to the file using the variable "workbook". You are also able to provide the specific downloadFileName you wish to use. Using the postGenerationProcess property you should be able to make a call to a Java method that makes the connection to your network drive where you can use the "workbook" variable and downloadFileName value to save your document. If this doesn't work definitely post a question on their project site because the creator does reply.

vb.net external manipulation commands

I tried to find this but I'm not exactly sure how to search for it or if it would even be possible. I'm trying to integrate a program I wrote with a commercial app, the commercial app has the ability to call an external program with a command and pass it the data that I want to capture.
I want to be able to get the currently open instance (or whichever responds first in the case of multiple instances) and send it the information directly and have it perform a function based on that information, I don't want to have to open a new instance.
I know one of my options is to drop a text file with the info and then have my program watch for it and parse it once found but if I can do a more direct communication I'd rather do that.
all it needs to do is fill a text box and run a function seems simple enough, and all I need is a point in the wright direction or some search terms that would pull up pertinent results. I'd like to understand how it works instead of just having someone write the code for me.
Thanks