====== Running Chrome ======
===== URLs =====
* http://www.ghacks.net/2013/10/06/list-useful-google-chrome-command-line-switches/
* http://www.r-bloggers.com/integrating-python-and-r-part-ii-executing-r-from-python-and-vice-versa/
* https://stat.ethz.ch/pipermail/r-help/2013-October/361397.html
* https://bugs.r-project.org/bugzilla3/show_bug.cgi?id=16127
* https://developer.mozilla.org/en-US/docs/Mozilla/Command_Line_Options
* http://www.chromium.org/developers/how-tos/run-chromium-with-flags
* https://www.linkedin.com/pulse/command-line-switches-chrome-driver-evgeny-tkachenko-6024124673334214656
* http://www.thegeekstuff.com/2011/10/google-chrome-commands/
* https://adestefawp.wordpress.com/software/chromium-command-line-switches/
* http://www.windows-commandline.com/open-chrome-from-command-line/
* http://gojs.net/latest/index.html?gclid=CNCSv7KF2s0CFZEy0wodRJYBfw
* http://vlado.fmf.uni-lj.si/test/vis/forceM.html
* http://vlado.fmf.uni-lj.si/test/vis/forcea.html
* http://stackoverflow.com/questions/11582512/how-to-get-url-parameters-with-javascript
* http://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-url-parameter
* http://stackoverflow.com/questions/11832930/html-input-file-accept-attribute-file-type-csv
===== Command line call =====
C:\Program Files (x86)\Google\Chrome\Application\Chrome.exe
chrome://flags
chrome://about
chrome.exe -incognito --app=google.com
chrome.exe -incognito --new-window mytargetpage.com
"c:\progra~2\Google\Chrome\Application\chrome.exe" --chrome-frame --kiosk http://foldoc.org/pub/misc/automata.html
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --user-data-dir=XXXXXXXXXX --window-size=800,600 --window-position=580,240 --app="http://www.google.com/"
or
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --chrome-frame --window-size=800,600 --window-position=580,240 --app="http://www.google.com/"
"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"
--profile-directory="Default"
--app="data:text/html,"
--window-size=w,h
google-chrome "data:text/html;charset=ISO-8859-1,
"
give a nice way to do this.
Nota: This work as well with firefox too.
I'm not aware of a way to read command line params, but you can pass a URL to Chrome
on the command line, and you can detect that URL being loaded. So a hack would be to call
chrome.exe http://fakeurl.com/?all-the-data-you-need-to-pass
and have your extension redirect this URL to the new tab page and then act according to
the data in the querystring.
If you’re comfortable with the command line, you can also change Chrome’s behavior
by launching it with command line flags. For example, the command below launches
Chromium (the open-source version of Chrome) and tells it to cycle through the list
of URLs in the specified text file, then exit:
/Applications/Chromium.app/Contents/MacOS/Chromium --visit-urls=/Users/cantrell/tmp/urls.txt
===== Call from R =====
> chrome <- "C:/Program Files (x86)/Google/Chrome/Application/Chrome.exe"
> args <- c("http://vlado.fmf.uni-lj.si",
+ "-incognito",
+ "--app=google.com",
+ "--window-size=500,300" )
> system2(chrome,invisible=TRUE,wait=FALSE,args=args)
**''ERgraphJS.R''**
setwd("C:/Users/batagelj/work/Python/graph/SVG")
dice <- function(n=6){return(1+trunc(n*runif(1,0,1)))}
ErdosRenyiNet <-
# generates a random undirected graph of Erdos-Renyi type
# with n vertices and m edges, and stores it on the file
# fnet in netJSON format.
# Example: ErdosRenyiNet('testER.net',100,175)
# -------------------------------------------------------
# by Vladimir Batagelj, R version: Ljubljana, 20. Dec 2004
# based on ALG.2 from: V. Batagelj, U. Brandes:
# Efficient generation of large random networks
# Addapted for netJSON by V. Batagelj, Piran, 4. Jul 2016
function(fnet,n,m){
net <- file(fnet,"w");
head <- paste('graph = {\n "netJSON": "basic",\n',
' "info":{"network": "ERgraph",',
'"org": 0, "nNodes": ', n, ', "nEdges": ', m,
', "meta" : { "date": "July 4, 2016" }},\n "nodes": [',sep='')
cat(head,file=net)
for (i in 1:n) cat(' {"id": ',i-1,',"name": "v',i-1,'", "group": ',dice(6),
'}', ifelse(i==n,'',','),'\n',sep='',file=net)
cat(' ],\n "links": [',file=net); L <- new.env(parent = baseenv())
for (i in 1:m){
repeat { u <- dice(n)-1; v <- dice(n)-1
if (u!=v) {
edge <- if (u
**''forceNet.js''**
function forceNet(V,L){
// addapted from
// Mike Bostock’s Block: Force-Directed Graph
// http://bl.ocks.org/mbostock/4062045
var color = d3.scale.category20();
var force = d3.layout.force()
.charge(-120)
.linkDistance(30)
.size([width, height]);
var svg = d3.select("body").append("svg")
.attr("width", width)
.attr("height", height);
force
.nodes(V)
.links(L)
.start();
var link = svg.selectAll(".link")
.data(L)
.enter().append("line")
.attr("class", "link")
.style("stroke-width", function(d) { return Math.sqrt(d.value); });
var node = svg.selectAll(".node")
.data(V)
.enter().append("circle")
.attr("class", "node")
.attr("r", 5)
.style("fill", function(d) { return color(d.group); })
.call(force.drag);
node.append("title")
.text(function(d) { return d.name; });
force.on("tick", function() {
link.attr("x1", function(d) { return d.source.x; })
.attr("y1", function(d) { return d.source.y; })
.attr("x2", function(d) { return d.target.x; })
.attr("y2", function(d) { return d.target.y; });
node.attr("cx", function(d) { return d.x; })
.attr("cy", function(d) { return d.y; });
});
};
**''ForceJS.html''**
chrome <- "C:/Program Files (x86)/Google/Chrome/Application/Chrome.exe"
args <- c("C:/Users/batagelj/work/Python/graph/SVG/ForceJS.html",
"-incognito",
"--app=google.com",
"--window-size=500,300" )
system2(chrome,invisible=TRUE,wait=FALSE,args=args)
**''readForce.html''**