Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com.
Your code must open the browser itself, and cannot rely on an open one.
This is code-golf, so the shortest answer in bytes wins.
Code Golf Stack Exchange is a question and answer site for programming puzzle enthusiasts and code golfers. It only takes a minute to sign up.
Sign up to join this communityYour job is to open a browser window of the default browser to http://codegolf.stackexchange.com.
Your code must open the browser itself, and cannot rely on an open one.
This is code-golf, so the shortest answer in bytes wins.
(eww"ppcg.ga")
EWW is a browser inside Emacs. The browse-web
function is an alias for eww
, and so that makes eww
the default browser in Emacs:
Your job is to open a browser window of the default browser to http://codegolf.stackexchange.com.
Thanks to @CoolestVeto, @Jonathan Leech-Pepin and @zyabin101.
www.ppcg.lol
instead of http://ppcg.lol
?
\$\endgroup\$
– AdmBorkBork
Mar 30 '16 at 15:55
//
, I don't think. (I don't use emacs, but it's generally accepted without the //
)
\$\endgroup\$
– Addison Crump
Mar 30 '16 at 19:03
Not winning, but sure was fun. As of right now, I'm only 1 bytee behind python!
I need webbrowser
Now open "http:ppcg.ga"
Explanation:
I need
compiles to import $1
with webbrowser
being the module.
Now
runs the following command from the module as module.command
with the arguments of anything following.
So this compiles to:
#!/usr/bin/env python3
import webbrowser
webbrowser.open("http:ppcg.ga")
I do end up needing the http:
part though, and it can't be shortened.
"http://ppcg.lol"
with "http:ppcg.lol"
. I'm uncertain whether you can remove the space between open
and "http:..."
, but try it?
\$\endgroup\$
– Addison Crump
Mar 30 '16 at 19:01
Saved 3 bytes thanks to Mego.
start www.ppcg.ga
This will open in your default browser if you run it from the windows command line.
I think it'll work in Powershell too, but I'm not sure.
start
instead of explorer
.
\$\endgroup\$
– user45941
Mar 30 '16 at 15:07
start www.ppcg.lol
instead to implicitly have Windows parse it as HTTP. Works in both CMD and PowerShell.
\$\endgroup\$
– AdmBorkBork
Mar 30 '16 at 15:37
saps www.ppcg.lol
Using an even shorter domain provided by Milo.
saps www.ppcg.ga
While start
is a known alias for Start-Process
there is another one for saps
. You can see this from Get-Alias
. It follows the convention for similar Start-
and Stop-
cmdlets.
open http:ppcg.ga
Saved 2 thanks to CoolestVeto
open
is an OSX utility, not a bash one; this would be more appropriately called "OSX command line".
\$\endgroup\$
– Skyler
Mar 30 '16 at 15:17
open http:ppcg.ga
\$\endgroup\$
– DarkDust
Apr 2 '16 at 13:52
web www.ppcg.lol -browser
www
is shorter than http://
and ensures that the address is processed as a URLweb('www.ppcg.lol', '-browser')
.web ppcg.lol -browser
as MATLAB will automatically append an http://
(21 bytes)Alternatives:
On windows this can be shortened to (19 bytes)
!start www.ppcg.lol
On OS X (21 bytes)
!open http://ppcg.lol
The following would work in a deployed MATLAB application (16 bytes)
web www.ppcg.lol
If the built-in browser could be used this could be reduced even further as http
is implied (12 bytes)
web ppcg.lol
open
command does the same.
\$\endgroup\$
– noɥʇʎԀʎzɐɹƆ
Mar 30 '16 at 15:50
!
does in MATLAB, it's the equivalent of system(command)
. I had it as more of a demonstration of other alternatives that could be executed from within MATLAB. Is that OK?
\$\endgroup\$
– Suever
Mar 30 '16 at 15:53
www
is unnecessary only on OS X
\$\endgroup\$
– Suever
Mar 30 '16 at 21:10
Shamelessly borrowing that shortened link.
from webbrowser import*;open("http:ppcg.ga")
Thanks to CrazyPython for -4 bytes, and Sp3000 for a further one.
Edit: shaved 2 more off thanks to CoolestVeto
Edit: thanks to MD XF for registering ppcg.ga and saving another byte
python -m webbrowser -t http:ppcg.lol
which I think counts as 30 chars
\$\endgroup\$
– gnibbler
Mar 31 '16 at 6:24
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:48
xdg-open http:ppcg.lol
Not as short as some others. firefox ppcg.lol
is shorter, but it doesn't meet question spec.
xdg-open www.ppcg.lol
works for me as well.
\$\endgroup\$
– Digital Trauma
Mar 30 '16 at 17:47
xdg-open http:ppcg.lol
also works for me.
\$\endgroup\$
– Digital Trauma
Mar 30 '16 at 20:18
class P{public static void main(String[]a)throws Exception{java.awt.Desktop.getDesktop().browse(new java.net.URI("http://ppcg.lol"));}}
Java is not the best language for golfing... Here's the same program in a more readable format:
class P {
public static void main (String[] a) throws Exception {
java.awt.Desktop.getDesktop().browse(new java.net.URI("http:ppcg.ga"));
}
}
Saved 2 bytes by removing //
in the URI/L, and another byte by switching to .ga
from .lol
(indirectly thanks to @Milo)
"http://ppcg.lol"
with "http:ppcg.lol"
\$\endgroup\$
– Addison Crump
Mar 30 '16 at 18:59
interface P{static void main(String[]a)throws Exception{java.awt.Desktop.getDesktop().browse(new java.net.URI("http:ppcg.ga"));}}
Java is not the best language for golfing... Here's the same program in a more readable format:
interface P {
static void main (String[] a) throws Exception {
java.awt.Desktop.getDesktop().browse(new java.net.URI("http:ppcg.ga"));
}
}
Saved 2 bytes by removing //
(thanks @CoolestVeto), and another byte by switching to .ga
from .lol
(indirect thanks to @Milo)
interface
is longer than class
, you save more bytes because the public
modifier is implied.
\$\endgroup\$
– HyperNeutrino♦
Mar 31 '16 at 19:32
require('open')('http://ppcg.lol')
Uses Node.js
require`open``http://ppcg.lol`;
(added ;
to avoid tripping the formatting)
\$\endgroup\$
– Ismael Miguel
Mar 31 '16 at 8:17
require('open')('//ppcg.lol')
to save 5 bytes
\$\endgroup\$
– Martijn
Mar 31 '16 at 11:56
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:48
(require net/sendurl)(send-url"ppcg.ga")
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:49
open location"http:ppcg.lol"
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:49
SystemOpen@"http://ppcg.lol"
shell.exec("www.ppcg.lol")
I don't know of any shorter way to do this in R.
system
/fork
/whatever call is a trivial modification.
\$\endgroup\$
– user45941
Mar 30 '16 at 19:40
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:49
package{import flash.display.Sprite;public class A extends Sprite{function A(){navigateToUrl("ppcg.lol","_blank")}}}
Like Java, this is not a great golfing language. Here's the code with formatting:
package
{
import flash.display.Sprite;
public class A extends Sprite
{
function A()
{
navigateToUrl("ppcg.lol", "_blank")
}
}
}
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:49
browse"ppcg.ga"
if you accept an error before opening the page on Linux, no error on Windows
20 bytes without an error
browse http:ppcg.lol
browse #ppcg.lol
\$\endgroup\$
– Izkata
Apr 1 '16 at 20:02
Should work everywhere, but needs that import :(
8 bytes saved with @msh210 comment.
use Browser::Open open_browser;open_browser"http:ppcg.ga"
Also, for funsies :
system "start http://www.ppcg.ga"
system "xdg-open http:ppcg.ga"
-M
instead of use
to shave a coupla bytes. (Untested.) Also, I'm guessing you don't need the parens or the www.
. (Also untested.)
\$\endgroup\$
– msh210
Apr 1 '16 at 21:40
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:49
(ext:shell "open http:ppcg.ga")
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway. Also, couldn't the space between BROWSE
and "
be removed, saving another byte?
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:50
I used to have lots of fun creating tiny programs in VBScript, back in 2010.
I've remembered this language and used the code on: https://stackoverflow.com/a/13401872/2729937
It still works on Windows 7, at least.
set S=CreateObject("WScript.Shell")
S.run("www.ppcg.ga")
This is a bit different from the usual start www.ppcg.lol
, in the sense that it executes the www.ppcg.ga
directly, with an implicit start
.
An alternative way would be "cmd.exe /C start www.ppcg.ga"
.
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:50
Process.Start("http://ppcg.lol");
Opens the default browser to the web address
System.Diagnostics
namespace to be added in or Process
to be fully qualified to work.
\$\endgroup\$
– TheLethalCoder
Apr 1 '16 at 15:25
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:50
Non-competing, since the features used here postdate the challenge. Code:
’…Ò ™³.ÐÏg.´¢’.E
You can try the string online here. This basically evaluates to this batch answer.
Uses the CP1252 encoding.
Process.Start("http:ppcg.lol")
Sub Main()
, and +7 for End Sub
, which you need in order to run this at least in a VB.NET console program, also you would need to import System.Diagnostics
.
\$\endgroup\$
– MrSuttonmann
Apr 12 '16 at 12:26
ppcg.lol
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:50
[ "http:ppcg.ga" open-url ]
I didn't know one could golf-off the //
in the protocol.
run-process
, and you can wholly drop //
.
\$\endgroup\$
– Addison Crump
Mar 30 '16 at 19:16
//
could be left off. As for the space between "
and run-process
, dropping that would require a word named "run-process
to be present in the current vocabulary search path
\$\endgroup\$
– cat
Mar 30 '16 at 19:22
system
/fork
/whatever call is a trivial modification.
\$\endgroup\$
– user45941
Mar 30 '16 at 19:35
xdg-open
in languages which are not equipped with special functions for browsing the web. A C or ASM answer would surely also have to do system("xdg-open...")
\$\endgroup\$
– cat
Mar 30 '16 at 19:44
start www.gfa1.tk
gfa1.tk
has been unregistered, invalidating this answer :I However, I just registered ppcg.ga
, so you can use that instead, saving a byte anyway.
\$\endgroup\$
– MD XF
Jul 26 '17 at 3:52
from webbrowser import*;open('http:ppcg.ga')
URL from this comment
Edit: ppcg.ga seems to become more popular now (but it WAS available when I posted this answer).
Ungolfed:
from webbrowser import * # Loads everything in the webbrowser module
open("http://ppcg.ga/") # Opens default browser to http://ppcg.ga/
from webbrowser import*;open('http:gfa1.tk')
URL from this answer
Ungolfed:
from webbrowser import * # Loads everything in the webbrowser module
open("http://gfa1.tk/") # Opens default browser to http://gfa1.tk/
from webbrowser import*;open('http:ppcg.lol')
Ungolfed:
from webbrowser import * # Loads everything in the webbrowser module
open('http://ppcg.lol/') # Opens default browser to http://ppcg.lol/
Take that, ppcg.lol! (1 byte shorter)
Note: I added a separate answer leading to ppcg.lol, 'cause I've noticed the other sites doesn't work for me in Internet explorer 11, and I saw other users having this problem too.
Both are non-non-competing (read that right?)
`open http:ppcg.ga`
Simple.
Thanks to Daniel for 2 bytes off.
%x
. open http:ppcg.lol
\$\endgroup\$
– Daniel Evans
Mar 31 '16 at 7:31