33
\$\begingroup\$

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 , so the shortest answer in bytes wins.

\$\endgroup\$
  • 8
    \$\begingroup\$ Are URL shorteners allowed? \$\endgroup\$ – isaacg Mar 30 '16 at 15:01
  • 4
    \$\begingroup\$ Is it allowed to run JavaScript in the default browser to open a window? \$\endgroup\$ – Mwr247 Mar 30 '16 at 15:30
  • 4
    \$\begingroup\$ @Mwr247 No, it is not. \$\endgroup\$ – noɥʇʎԀʎzɐɹƆ Mar 30 '16 at 15:49
  • 15
    \$\begingroup\$ You should add clarifications/restrictions to the question itself, since comments are not guaranteed to stick around forever. \$\endgroup\$ – Mego Mar 30 '16 at 16:01
  • 8
    \$\begingroup\$ Your spec is minimal, which led to alot of uncertainty over what is allowed to accomplish the task. Additionally, some probably consider it a trivial task. Still, you're in the positive ;) \$\endgroup\$ – Mwr247 Mar 30 '16 at 17:16

47 Answers 47

1
\$\begingroup\$

NodeJS, 53 bytes

require('child_process').exec('open http://ppcg.lol')

Works on mac.

\$\endgroup\$
  • 2
    \$\begingroup\$ Duplicate of this \$\endgroup\$ – Mego Mar 30 '16 at 18:58
  • \$\begingroup\$ 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:51
1
\$\begingroup\$

Game Maker Studio, 26 bytes

url_open('http://ppcg.ga')
\$\endgroup\$
  • \$\begingroup\$ This is not a complete program. Anyway, have +1 for using GameMaker Studio xDDDDDD \$\endgroup\$ – Luis Masuelli Apr 8 '16 at 21:18
  • \$\begingroup\$ @LuisMasuelli Yes it is. No need to use a script or anything - there is a way to run "creation code" in the room settings, which is usually how you would run any GML code for this site. But thanks ;) \$\endgroup\$ – Timtech Apr 8 '16 at 22:58
  • \$\begingroup\$ U're right. There's actually no way of posting a complete program since most of the execution is not done by explicit code but GMS internal lifecycle. \$\endgroup\$ – Luis Masuelli Apr 8 '16 at 23:00
  • \$\begingroup\$ @LuisMasuelli Yes, that's why I usually only use the GML code script in the objects and room creation code, none of the drag-and-drop anymore. \$\endgroup\$ – Timtech Apr 8 '16 at 23:02
1
\$\begingroup\$

PHP (OSX), 33 bytes

<?php exec("open http:ppcg.lol");

PHP (Windows), 34 bytes

<?php exec("start http:ppcg.lol");
\$\endgroup\$
  • \$\begingroup\$ "'open' is not recognized as an internal or external command, operable program or batch file." \$\endgroup\$ – Dewi Morgan Apr 1 '16 at 18:06
  • \$\begingroup\$ 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:51
1
\$\begingroup\$

C++, 61 Bytes

#include <cstdlib>
main(){system("xdg-open http:ppcg.lol");}

Just a rip off of the bash solution using system, and it only works on systems using the freedesktop tools. Also shortened by using the short link some kindly provided, otherwise it would be much longer.

\$\endgroup\$
  • \$\begingroup\$ 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:51
1
\$\begingroup\$

Windows Batch, 17 bytes

start www.gfa1.tk
\$\endgroup\$
  • \$\begingroup\$ You should include the language for this. Also, this is a trivial improvement upon an existing answer, and thus it should have been a comment rather than a separate answer. \$\endgroup\$ – Mego Apr 2 '16 at 2:14
  • \$\begingroup\$ ppgc.ga is working now. \$\endgroup\$ – Tim Apr 2 '16 at 20:35
  • \$\begingroup\$ 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
1
\$\begingroup\$

Perl 6, 45 bytes

Requires the Browser::Open module.

use Browser::Open;open_browser 'http:ppcg.ga'
\$\endgroup\$
  • \$\begingroup\$ Do you really need that one whitespace? I can't test this right now. \$\endgroup\$ – cat Apr 29 '16 at 12:26
  • \$\begingroup\$ Yes, Perl 6 has strict whitespace requirements. \$\endgroup\$ – Ming-Tang Apr 30 '16 at 3:34
1
\$\begingroup\$

Lua, 30 Bytes

os.execute'start http:ppcg.ga'
\$\endgroup\$
1
\$\begingroup\$

Python, 43 41 40 bytes

import os
os.system("open http:ppcg.ga")
  • -2 bytes thanks to @Quill.
  • -1 byte thanks to @MDXF.
\$\endgroup\$
  • \$\begingroup\$ Duplicate of this \$\endgroup\$ – Mego Mar 30 '16 at 18:57
  • 4
    \$\begingroup\$ @mego how is it a duplicate - It's not even the same language! \$\endgroup\$ – proud haskeller Mar 30 '16 at 22:30
  • \$\begingroup\$ @proudhaskeller See my comments on this answer \$\endgroup\$ – Mego Mar 30 '16 at 23:56
  • \$\begingroup\$ @mego on the nominations for moderator you said yo believe in hands-off moderation. I don't see how this is reflected here. \$\endgroup\$ – proud haskeller Mar 31 '16 at 6:03
  • \$\begingroup\$ @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. \$\endgroup\$ – Mego Mar 31 '16 at 6:10
1
\$\begingroup\$

C# (Full Class) 89 bytes

class P{static void Main(string[]a){System.Diagnostics.Process.Start("http://ppcg.ga");}}

Not sure that it's possible to write a full class (with the System.Diagnostics reference) any shorter.

Inside main method only without references, 32 bytes:

Process.Start("http://ppcg.ga");
\$\endgroup\$
  • \$\begingroup\$ 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:51
1
\$\begingroup\$

Dyalog APL, 20 19 bytes

-1 byte thanks to MD XF

]Open http://ppcg.ga

Uses the User Command ]Open, which is installed with Dyalog.

\$\endgroup\$
  • \$\begingroup\$ Needs you the //? \$\endgroup\$ – Addison Crump Mar 30 '16 at 19:31
  • 1
    \$\begingroup\$ @CoolestVeto Yes, otherwise you get an error: * Command Execution Failed: File not found \$\endgroup\$ – Adám Mar 30 '16 at 19:34
  • \$\begingroup\$ 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:52
  • \$\begingroup\$ @PatrickRoberts Thanks. Half an edit. I must have become distracted in the middle. \$\endgroup\$ – Adám Jul 27 '17 at 21:12
0
\$\begingroup\$

R, 28 bytes

browseURL("http://ppcg.lol")

(in utils package)

\$\endgroup\$
  • 1
    \$\begingroup\$ 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:52
0
\$\begingroup\$

SX, 38 bytes (might be non-competing)

的 webbrowser im**;o&('http:ppcg.ga')

Save this shell script as SXexec.sh to your SX directory:

#!/bin/sh
N=$1.py;python Main.py $1;wine SXCompiler.exe $N;rm $N;python $N.py;rm $N.py

The script features tidying up after execution. To execute the above script, you need to have Wine and Python. Usage is like this:

SXexec.sh file
\$\endgroup\$
0
\$\begingroup\$

Nim, 47 bytes

import browsers
openDefaultBrowser"www.ppcg.ga"
\$\endgroup\$
  • \$\begingroup\$ 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:52
  • \$\begingroup\$ ppcg.ml also works \$\endgroup\$ – Skidsdev Jul 26 '17 at 8:07
0
\$\begingroup\$

Python, 40 bytes

__import__('webbrowser').open('ppcg.ga')

Shorter version of everything else.

\$\endgroup\$
0
\$\begingroup\$

VBScript, 47 bytes

CreateObject("WScript.Shell").Run"http:ppcg.gq"
\$\endgroup\$
0
\$\begingroup\$

C (gcc), 49 38 37 bytes

main(){system("start http:ppcg.ga");}

It's for Windows.

\$\endgroup\$
0
\$\begingroup\$

URL, 58 bytes

[InternetShortcut]
URL=https://codegolf.stackexchange.com

In Windows create a file "url.URL", with a code editor put the code.

\$\endgroup\$
  • 1
    \$\begingroup\$ Welcome to the site! As it isn't clear whether this works or not, could you provide either instructions for running this, or a link to an online testing environment such as TryItOnline!, so that others can verify your answer? \$\endgroup\$ – caird coinheringaahing Sep 21 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.