Re: Vibe.d: Listening to port 8080 on external device doesn't work
On Wednesday, 22 February 2017 at 00:38:30 UTC, aberba wrote: Using vibe.d, I bind to port 8080 at 127.0.0.1 but I can't access server on my phone through hotspot using the external IP from ip addr on Linux. But 127.0.0 running Apache server works. Don't if its vibe.d or OS (ubuntu 14.04) How do I reached my vibe.d server in this case on my phone? Listen on "0.0.0.0".
Object.factory from shared libraries
I'd like to extend my program's functionality from plugins, that'd be loaded by name (or not) as requested by the config file. Is it possible to throw in a few dlls/sos implementing those new modules into a directory and hope that they will be all loaded and available to Object.factory in the main executable? I hope I'm clear enough.
Re: Object.factory from shared libraries
On Friday, 26 September 2014 at 14:14:05 UTC, Jacob Carlborg wrote: On 26/09/14 14:37, krzaq wrote: I'd like to extend my program's functionality from plugins, that'd be loaded by name (or not) as requested by the config file. Is it possible to throw in a few dlls/sos implementing those new modules into a directory and hope that they will be all loaded and available to Object.factory in the main executable? I hope I'm clear enough. If you either enumerate all dynamic libraries in a directory, or a list from a config file, then use dlopen on all libraries. Then I think Object.factory should work. But dynamic libraries are basically only working on Linux. That would be satisfactory to me, except for the linux-only part. In that case, I think I'll simply try to call filename() as the factory function in each library - that should work everywhere, right?
Re: input range from stdin
On Wednesday, 17 September 2014 at 18:05:36 UTC, Ali Çehreli wrote: On 09/17/2014 08:30 AM, krzaq wrote: On Wednesday, 17 September 2014 at 14:37:21 UTC, Marc Schütz wrote: On Wednesday, 17 September 2014 at 12:44:00 UTC, krzaq wrote: I'd like to have something similar to C++'s std::istream_iteratorint(std::cin) Is it possible? I'm relatively indifferent to efficiency of the solution. import std.stdio; import std.algorithm; import std.conv; writeln(stdin.byLine.map!(to!int)); What happens if I later have some strings that I want to read from the same line? How can I use the resultant range with std.fill? My idea doesn't seem to work: http://dpaste.dzfl.pl/130e14c927f3 The following worked: import std.stdio; import std.format; import std.exception; import std.string; import std.algorithm; struct Data { int i; string s; } Data toData(char[] line) { int i; string s; auto slice = line; const items = formattedRead(line, %s %s, i, s); enforce (items == 2, format(Incomplete line: %s, slice)); return Data(i, s); } void main() { auto data = stdin.byLine.map!toData; writeln(data); } I could not get it work with fill because fill requires specific types of ranges, which neither the destination nor the source were. For example, I wanted to use std.array.Appender but fill wants an InputRange. Also, the source is not a ForwardRange because it is consuming from stdin. However, it is easy to make an array with std.array.array: import std.array; writeln(data.array); Ali Thank you for your reply. That's not what I wanted. Maybe I should explain instead of expecting you to divine my intentions, though :) I am trying to rewrite the following program in D--making it more elegant: http://melpon.org/wandbox/permlink/ff42FoyKgqJK60sm As you can see, I can have one input line consisting of n words and then n integers and I can read from it easily. My question whether stdin.byLine allows me to do this remains unanswered (or I failed to understand the answer), although I am not hopeful. As to std.fill: I find myself surprised. Any idea why the input range is considered incorrect? In any case, should integers[0..$].fill(...) not make it correct, at least in regards to the first argument? Docs have an example with int[] I expected my D code to look more or less like the following: words.fill(stdin.by!string); integers.fill(stdin.by!int); zip(integers,words).map!(p = p[1][p[0]]).join.writeln;
Re: input range from stdin
On Thursday, 18 September 2014 at 11:13:36 UTC, Marc Schütz wrote: On Thursday, 18 September 2014 at 09:21:17 UTC, krzaq wrote: That's not what I wanted. Maybe I should explain instead of expecting you to divine my intentions, though :) I am trying to rewrite the following program in D--making it more elegant: http://melpon.org/wandbox/permlink/ff42FoyKgqJK60sm As you can see, I can have one input line consisting of n words and then n integers and I can read from it easily. My question whether stdin.byLine allows me to do this remains unanswered (or I failed to understand the answer), although I am not hopeful. You should be able to use `std.algorithm.take` to read exactly 5 integers. However, in order to read up to the first empty line, for example, the input would have to be a forward range (= rewindable), which stdin.byLine of course is not. Maybe you could constructor a wrapper range that caches input lines as necessary. Okay, I think I'll simply skip this for now. I hoped that there would be a way of reading stdin composable with std.algorithms, as is the case in C++. I guess this works for now http://dpaste.dzfl.pl/6801615160e3 I have a follow-up question: why does zip not accept an array?
input range from stdin
I'd like to have something similar to C++'s std::istream_iteratorint(std::cin) Is it possible? I'm relatively indifferent to efficiency of the solution.
Re: input range from stdin
On Wednesday, 17 September 2014 at 14:37:21 UTC, Marc Schütz wrote: On Wednesday, 17 September 2014 at 12:44:00 UTC, krzaq wrote: I'd like to have something similar to C++'s std::istream_iteratorint(std::cin) Is it possible? I'm relatively indifferent to efficiency of the solution. import std.stdio; import std.algorithm; import std.conv; writeln(stdin.byLine.map!(to!int)); What happens if I later have some strings that I want to read from the same line? How can I use the resultant range with std.fill? My idea doesn't seem to work: http://dpaste.dzfl.pl/130e14c927f3
How to set workDir for std.process.execute ?
Hello, I'm trying to follow the documentation: http://dlang.org/phobos/std_process.html#.execute Unfortunately, the following code gives me a compiler error: class Probator { char[] dir; this(const char[] dir){ this.dir = dir.dup; } int revision(){ import std.process; import std.conv; const char[] workDir = ~.dup; auto p = std.process.execute([svnversion, dir], null, Config.none, size_t.max, workDir); if(p.status == 0){ return to!int(p.output); }else{ throw new Exception(p.output); } } } error: /d629/f876.d(15): Error: function std.process.execute (const(char[][]) args, const(immutable(char)[][string]) env = null, Config config = cast(Config)0, ulong maxOutput = 18446744073709551615LU) is not callable using argument types (const(char)[][], typeof(null), Config, ulong, const(char[])) It's as if the implementation didn't expect the last argument.
Re: How to set workDir for std.process.execute ?
On Wednesday, 20 August 2014 at 16:16:03 UTC, ketmar via Digitalmars-d-learn wrote: On Wed, 20 Aug 2014 16:07:47 + KrzaQ via Digitalmars-d-learn digitalmars-d-learn@puremagic.com wrote: It's as if the implementation didn't expect the last argument. try to upgrade to dmd 2.066. That did the trick. Thanks.