R: reload google chrome URL if already loaded - r

I am using an Rscript to load an .html file with Google Chrome via browseURL("myfile.html"). However, I would like the Rscript to first check if the URL is already open in Chrome, and if so, just reload the URL. I don't want it to open the URL in a new Chrome tab. Is there a way to achieve this?

You can get to work with the help of some third-party components.
When you call Rscript's browseURL function, it's just running whatever program it thinks is the browser and passing it your URL. You can tell it to use whatever "browser" you want:
browseURL("file:/path/to/my/file.html",
browser = "/path/to/chrome_reloader.sh")
You can use the Chromix Too package to control Chrome. You will have to install a few things, but it's easy and only takes a few minutes:
Install the Chromix Too extension from the Chrome web store.
Install the latest version of NodeJS.
Use npm (installed with NodeJS) to install Chromix Too.
Run the Chromix Too server.
Now you run commands like chromix-too ls to see a list of all the tabs you have open in Chrome and chromix-too reload http://some.web.site/ to reload one of them.
Now you can write the chrome_relauncher.sh script that just passes whatever URL it gets to chromix-too reload:
#!/bin/bash
chromix-too reload $1
It looks like reload only reloads a tab that already exists but won't open a new one. You could use the ls command to first check if the tab exists; it looks like chromix-too ls 'http://some.site/path' returns success (0) if the tab exists and failure (1) if it doesn't, so you could use that in your script. Or just open the tab manually before running your Rscript program. There's also a file command that loads a local file and specifically says it will reuse and reload an existing tab.
You may need to tweak a few things (maybe add the path to chromix-too which you can get with which chromix-too) but this should basically work.

Related

Directory issue when connecting VS Code to remote server via ftp-simple

I've set up ftp-simple to connect to my remote server. Files show up fine, however directories appear with [DIR] next to them which, when clicked, disappear with a red line through it, as per image below (template-parts was the directory which I had just clicked on).
As mentioned, files are fine - they load perfectly, but it's the directories which have the issue.
Nothing shows up in the output log when this happens and I can't seem to find anything about this issue elsewhere.
The only solution I have found is this.
In vscode, go File->Preferences->Settings.
Then at the search area type this -> ftp-simple.remote-workspace-load-all <- and set it to false.
What this does is, when you first load a directory (the default path that has been set in vsc config), vsc is going to load only the content of this specific directory.
Then, only if you click another directory ([DIR]), it will start to download the content of this directory.

I accidentally added an 'exit' in my CloudShell .bashrc, cannot get back to edit it, it exits immediately

While learning about/customizing my GCP Cloud Shell startup environment I inadvertently added an 'exit' in my .bashrc and now cannot even get the shell up long enough to reset it when I click on the Cloud Shell icon from GCP dashboard -- how to reset it now? I really can't do anything to fix as Cloud Shell exits immediately trying to start up.
You can use gcloud alpha cloud-shell ssh with the option --command to rename the file as suggested in the comments to the question, or to simply sed that line out of existence.
The correct way to solve this is to enter Cloud Shell in safe mode. This will log you into Cloud Shell as root, allowing you to fix any issues with your regular user account.
OK, I fixed it. Solution is to click very quickly on the 'Editor' icon in top right of initial Cloud Shell window when it tries to open giving you a file list of your home directory which is stable and will stay open. Then go to 'Edit', 'Find in Files' and, in my case, search for 'exit'. But to find in hidden files such as .bashrc you need also to click the little eye icon to 'Include Ignored Files'. Edit, exit and restart a Cloud Shell instance and you're good.

Save search from Dev Tools

I'm a new user to Kibana 5.3.
I'm working on a search in "Dev Tools" panel. When I'm done with the code of the search, how do I save this search so it becomes available later for visualizations etc.?
it saves in local storage, so as long as you don't clear your browser cache, you're OK. You CAN, however append something like ?load_from=http://my-app/assets/kibana.json to your kibana URL and specify a json file which you save your queries to. This way you can possibly version them as well.
For example, I keep my queries in an assets folder for the project I'm working on and make sure I sync the 2 in case I have to blow away my cache. Note that a JSON linter will complain about the CURL-esque statements if you copy & save to that file.

Trying to use live server package on text editor atom

I am trying to use the live server package which works pretty much like livereload for editor Atom. The server runs fine, but the files do not get automatically refreshed whenever I make changes + save the files..
Not sure if this is normal, but when I open up the server on the browser, I am forwarded to a directory with all the files on the server. How do I change this so that the server renders HTML only and refreshes every time changes are made?
My php files with html elements dont open, so create the file like .html files, and everythings runs well. Use .atom-live-server.json on the root project to change some options like other browsers.
Edit 1: Have the solution !
1- Install Live Reload from livereload.com.
2- Install Live Reload from browser extension.
3- Copy and paste this before before body:
<script>document.write('<script src="http://' + (location.host || 'localhost').split(':')[0] + ':35729/livereload.js?snipver=1"></' + 'script>')</script>
4- Execute live reload and the browser and still works for php files.
You haven't set the project folder for the live-server to operate from, or you've saved the file you want to view outside of where it is running from.
In the project window on the left, add the project folder that you are using, and remove anything else. Or save your file in that location.
I had the same problem with atom-live-server and Google Chrome browser. Finally made it work using these steps:
Open your Browser
In Project pane open the project folder that you want to test
Start the atom-live-server
It should automatically open a new page in your browser. Right click on it and select Inspect -> it will open Console window.
Your Live reload is enabled. Notice the message in the Console.
After you make changes in your javascript or html in Atom save your changes (Ctrl + S) and the browser page will be updated.
I fixed it by adding the <head> and <body> tags to the html file I was editing. (even though I don't always include them anymore at least one is needed for the "Live reload" server to work.)
Live reload won't work unless there's a tag in the HTML the script can be injected on (body, head, and svg).
see this github issue!

How can I config workspace in chrome?

I'm trying to activate workspace tool for my local project. I want to apply CSS changes on my codes when I edit them into browser.
I've added my folder, perfix url and path of my project to the Chrome like this:
But still there isn't any change in my codes when I change it into browser, What's wrong?
Here are the steps to map a local workspace to a server path, using my example:
Click "Add folder" in the Workspace settings, and navigate to your working directory. Click "Allow" in the bar at the top to grant Chrome permissions.
Add a mapping between your server and the path
Load the URL and navigate to the Sources tab. Open your file and start editing.
If you save with Cmd+S (Mac) / Ctrl+S (Windows / Linux), the changes will be persisted in the workspace.
You can read more information from the official documentation here, which shows how to add it directly from the Sources panel. Read the Limitations section, in case you are trying to do something that isn't supported.

Resources