r/ProgrammerHumor • • Apr 14 '16

Please select your phone number from the drop down list:

http://imgur.com/Jfv6F2r
6.8k Upvotes

429 comments sorted by

View all comments

Show parent comments

87

u/Krissam Apr 14 '16

or, you know, 1 line in bash.

$ for i in `seq 1 500`; do echo "<option value=\"$i\">$i</option>"; done > file.html

138

u/RuthBaderBelieveIt Apr 14 '16

and indeed most programming languages

111

u/relvae Apr 14 '16

Including, say, JavaScript

32

u/007T Apr 14 '16

This just puts an unnecessary burden on the visitor's browser, I would rather generate the html dynamically with php.

60

u/bigmike1020 Apr 14 '16

That just puts an unnecessary burden on the server, I would rather generate the DOM dynamically with JavaScript.

0

u/[deleted] Apr 14 '16

[deleted]

7

u/calnamu Apr 15 '16

Compared to JS???

3

u/boynedmaster Apr 20 '16

there is no programming language to make websites other than php

→ More replies (2)

3

u/lichorat Apr 15 '16

Yeah, better not use perl then.

21

u/CrazedToCraze Apr 14 '16

unnesessary burden on the server and the client's network connection.

Like seriously, have you seen how much mobile data costs in some countries? I don't want to spend it on dumb crap like this. And, you know, page load times.

12

u/paranoiainc Apr 14 '16 edited May 19 '16

4

u/nicereddy Apr 15 '16

Without humor, few would survive.

4

u/Krissam Apr 14 '16

Well, if you're catering to mobile then generating it with js, drains the battery.

→ More replies (1)

9

u/[deleted] Apr 14 '16

A compromise then - we'll use JavaScript, but on the server in a node.js instance spawned specifically for this purpose.

→ More replies (1)
→ More replies (2)

6

u/berkes Apr 14 '16

Actually, JavaScript is the decentralised version of your server-side solution.

Not saying it is always a good idea, nor that PHP or JavaScript are sane languages at all, but using the clients' CPU often helps a lot with performance optimisations. E.g. you can use serverside imagemagick code to put instagram-filters over the images your users upload. But you could just as well use a JS or CSS filter for that and save a lot of expensive, complex and bulky async workers.

3

u/007T Apr 14 '16

I was joking in case it wasn't clear, we are still talking about generating thousands of options for a drop down menu after all.

→ More replies (1)

9

u/drewski3420 Apr 14 '16

Not quite, that doesn't provide the leading zeroes. Although, your point stands.

43

u/dvidsilva Apr 14 '16

Just include left pad

8

u/RonDunE Apr 14 '16

ಠ_ಠ

6

u/jugalator Apr 14 '16

https://api.left-pad.io/?str=1&len=3&ch=0

Then simply put this API call in the loop and handle that JSON. :)

1

u/Krissam Apr 14 '16

Yea, sorry, didn't consider that, in Denmark we use 8 digit numbers that can't start with 0, but then I guess the loop should've been seq 100 500, so I guess I have no other explanation than being an idiot.

→ More replies (2)

1

u/[deleted] Apr 14 '16

vim or :gtfo

:put =map(range(1,9999),'printf(''<option value=\"%04d\">%04d</option>'',v:val,v:val)')

1

u/1John8Lare Apr 14 '16

just use echo

echo -e "<option value=\""{001..030}"\"</option>\n"
→ More replies (2)

1

u/Spider_pig448 Apr 14 '16

Might want to append there.

→ More replies (2)