Re: Display a random image with vibe.d

2021-06-20 Thread pilger via Digitalmars-d-learn
On Sunday, 20 June 2021 at 12:34:33 UTC, vnr wrote: I don't understand why the image doesn't display, when I take an image from the internet and give the url, it works fine though. maybe this works: const auto rndimg = format("/images/rndimg/img%d.jpg", a); Also, is this a good way to

Re: Display a random image with vibe.d

2021-06-20 Thread jfondren via Digitalmars-d-learn
On Sunday, 20 June 2021 at 12:34:33 UTC, vnr wrote: I don't understand why the image doesn't display, when I take an image from the internet and give the url, it works fine though. ``` $ curl -s http://127.0.0.1:8080/|grep img ``` This is a relative URL, so to satisfy it the

Re: Display a random image with vibe.d

2021-06-20 Thread vnr via Digitalmars-d-learn
On Sunday, 20 June 2021 at 14:28:26 UTC, jfondren wrote: On Sunday, 20 June 2021 at 13:58:22 UTC, vnr wrote: Thanks for the answers, I understand better what is going on. So, what should I do to make my server respond with a random image, and not the random image page? I'm fairly new to

Display a random image with vibe.d

2021-06-20 Thread vnr via Digitalmars-d-learn
Hello, I would like to display a random image each time a page is refreshed. I think my random function works, but the image does not appear on the page. I have this template: ``` /public /images /rndimg img1.jpg img2.jpg img3.jpg /source

Re: Display a random image with vibe.d

2021-06-20 Thread vnr via Digitalmars-d-learn
On Sunday, 20 June 2021 at 13:06:20 UTC, jfondren wrote: On Sunday, 20 June 2021 at 12:34:33 UTC, vnr wrote: I don't understand why the image doesn't display, when I take an image from the internet and give the url, it works fine though. ``` $ curl -s http://127.0.0.1:8080/|grep img

Re: Display a random image with vibe.d

2021-06-20 Thread jfondren via Digitalmars-d-learn
On Sunday, 20 June 2021 at 13:58:22 UTC, vnr wrote: Thanks for the answers, I understand better what is going on. So, what should I do to make my server respond with a random image, and not the random image page? I'm fairly new to vibe.d, so I don't yet know the intricacies of how to handle

how to filter associative arrays with foreach ?

2021-06-20 Thread someone via Digitalmars-d-learn
I often need to iterate through a filtered collection (associative array) as following: ```d string strComputerIDunwanted = "WS2"; /// associative array key to exclude foreach (strComputerID, udtComputer; udtComputers) { /// .remove!(a => a == strComputerIDunwanted) ... ? if

do I incur a penality on compile time if I explicitly declare default behavior ?

2021-06-20 Thread someone via Digitalmars-d-learn
I mean, coding as following: ```d int intWhatever = 0; /// default being zero anyway foreach (classComputer objComputer, objComputers) { ... } /// explicitly declaring the type instead of letting the compiler to figure it out struc Whatever { public doSomething() { ... } /// explicitly

what is D's idiom of Python's list.extend(another_list)?

2021-06-20 Thread mw via Digitalmars-d-learn
i.e append an array of elements into another array: ```Python x = [1, 2, 3] x.extend([4, 5]) print(x) # [1, 2, 3, 4, 5] ``` Thanks.

is there a way to: import something = app-xyz-classes-something; ?

2021-06-20 Thread someone via Digitalmars-d-learn
Since memory serves I use to name files with - instead of the more common _