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.
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. |
|||||||||||||||||||||
|
Batch, 18 bytesSaved 3 bytes thanks to Mego.
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. |
|||||||||||||||||||||
|
Oration, 41 bytesNot winning, but sure was fun. :P TIED WITH PYTHON!!! :D
So this compiles to:
I do end up needing the The code being the same as an earlier revision of @Skyler's answer is a coincidence. This is the shortest possible Oration code, and I never saw the earlier revision for his answer. The only thing I did was upvote it when it had the "import *" part. |
|||||||||||||||||||||
|
PowerShell, 17 Bytes
While |
|||||
|
GNU Emacs,
|
|
|||
|
@TimmyD No, at first I tried with "www" but the protocol must be supplied (the behavior is different for example with "mailto://"). For user interaction, there is "browse-url-at-point" which prepends "http", but this is longer of course.
– coredump
Mar 30 at 16:47
|
||
|
You shouldn't need the
// , I don't think. (I don't use emacs, but it's generally accepted without the // )
– CoolestVeto
Mar 30 at 19:03
|
||
|
|||
|
Arguably this could be shortened to
(eww"ppcg.lol") sinceeww is now the default browser for Emacs itself. (browse-web is an alias for eww in the menu bar)
– Jonathan Leech-Pepin
2 days ago
|
Terminal (OSX),
|
|
open is an OSX utility, not a bash one; this would be more appropriately called "OSX command line".
– Skyler
Mar 30 at 15:17
|
||
|
|||
|
the first line: "Open a file in its default application, using virtual terminal (VT)." If you try to run that on unix, it will tell you "Couldn't get a file descriptor referring to the console", because it's trying to open in a terminal, not in a browser.
– Skyler
Mar 30 at 15:21
|
||
|
|||
|
MATLAB,
|
|
|||
|
@CrazyPython That's precisely what
! 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?
– Suever
Mar 30 at 15:53
|
||
|
|||
|
@CoolestVeto Sometimes you do sometimes you do not. When using the external browser you do, however the internal browser you do not. If you do not specify it, no browser window will open. If you can get it to work, I'm more than happy to change it!
– Suever
Mar 30 at 19:07
|
||
|
@CoolestVeto So I dug a little more and it looks like the
www is unnecessary only on OS X
– Suever
Mar 30 at 21:10
|
AutoHotKey, 16 bytes
|
|||||||||||||||||||||
|
|
|||||||||||||||||||||
|
Bash,
|
|
|||
|
@digital_trauma interesting, it didn't for me. It looked for www.ppcg.lol on the file system. Ubuntu 15.10.
– Ogaday
Mar 30 at 18:29
|
||
|
|||
|
|||
|
Python,
|
|
The former change leaves it exactly the same length. As for the http://, if you leave that out it tries to open a local file called "ppcg.lol", which doesn't exist.
– Skyler
Mar 30 at 15:27
|
||
|
|||
|
|||
|
I've always seen the
// as convention, I don't think you need it for some browsers.
– CoolestVeto
Mar 30 at 19:12
|
||
|
You can also do this with just command line options
python -m webbrowser -t http:ppcg.lol which I think counts as 30 chars
– gnibbler♦
Mar 31 at 6:24
|
JavaScript, 34 bytes
Uses Node.js |
|||||||||||||||||
|
Java 7, 118 bytes
Java is not the best language for golfing... Here's the same program in a more readable format:
|
|||||||||||||||||||||
|
Mathematica, 28 bytes
|
|||||||||||||||||||||
|
R, 26 bytes
I don't know of any shorter way to do this in R. |
|||||
|
Racket, 41 bytes
|
|||
|
Java 8, 115 bytes
Java is not the best language for golfing... Here's the same program in a more readable format:
|
|||||||||||||||||||||
|
Applescript, 28
|
||||
|
Actionscript 3, 117 bytes
Like Java, this is not a great golfing language. Here's the code with formatting:
|
||||
|
C#, 33 bytes
Opens the default browser to the web address |
|||||||||||||
|
Perl 5, 66 bytesShould work everywhere, but needs that import :(
Also, for funsies : Perl 5 (Windows), 34 bytes
Perl 5 (Unix), 31 bytes
|
|||||||||
|
VBScript, 57 bytesI used to have lots of fun creating tiny programs in VBScript, back in 2010. I've remembered this language and used the code on: http://stackoverflow.com/a/13401872/2729937 It still works on Windows 7, at least.
This is a bit different from the usual An alternative way would be |
|||
|
VB.NET,
|
|
|||||||||
|
Rebol2, 16 bytes
if you accept an error before opening the page 20 bytes without an error
|
|||||
|
Ruby,
|
|
You can save 2 characters by using backticks instead of
%x . open http:ppcg.lol
– Daniel Evans
2 days ago
|
||
|
|||
|
"'open' is not recognized as an internal or external command, operable program or batch file."
– Dewi Morgan
yesterday
|
||
|
NodeJS, 53 bytes
Works on mac. |
|||
Dyalog APL, 21 bytes
Uses the User Command ]Open, which is installed with Dyalog. |
|||||||||
|
05AB1E, 16 bytes (non-competing)Non-competing, since the features used here postdate the challenge. Code:
You can try the string online here. This basically evaluates to this batch answer. Uses the CP1252 encoding. |
|||||||||
|
Python,
|
|
|||
|
|||
|
|||
|
@mego on the nominations for moderator you said yo believe in hands-off moderation. I don't see how this is reflected here.
– proud haskeller
Mar 31 at 6:03
|
||
|
@proudhaskeller By hands-off moderation, I mean letting the community do all the moderation work that it can, rather than stepping in with mod powers. As I am neither a moderator nor using moderation powers/privileges, this is still hands-off moderation. If you wish to discuss my views on moderation further, I would encourage you to do so with me in the chatroom created specifically for that purpose.
– Mego
Mar 31 at 6:10
|
Factor,
|
|
I think you can remove the space between the end-quote and
run-process , and you can wholly drop // .
– CoolestVeto
Mar 30 at 19:16
|
||
|
@CoolestVeto Thanks! I didn't know the
// 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
– cat
Mar 30 at 19:22
|
||
|
|||
|
|||
|
@Mego Okay, well, not that it really matters but I did come up with this without seeing that one. But, there is really no other way to run The default browser without
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...")
– cat
Mar 30 at 19:44
|
Thank you for your interest in this question.
Because it has attracted low-quality or spam answers that had to be removed, posting an answer now requires 10 reputation on this site.
Would you like to answer one of these unanswered questions instead?