Vibe.d json to csv

2015-04-04 Thread Sebastiaan Koppe via Digitalmars-d-learn
So I am using vibe.d json module to parse some array data with homogeneous objects, and I want to convert it to CSV. Aside from encoding double-qoutes, this is want I came up with to generate the header: ``` void csvHeader(const Json jsonObject) { return

static array is no range?

2015-09-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
``` import std.algorithm; char[1024] buffer; buffer.find("LOCATION: "); // get error about how all the different versions of find don't match ``` ``` import std.algorithm; char[1024] buffer; buffer[0..$].find("LOCATION: "); // works as expected ``` Before trying the slice I manually

Re: Regression?

2015-09-06 Thread Sebastiaan Koppe via Digitalmars-d-learn
Dammit, i am on windows, DMD32 D Compiler v2.068.0

Regression?

2015-09-06 Thread Sebastiaan Koppe via Digitalmars-d-learn
This used to work in older compiler (might have been v2.067 or v2.066, not older). ``` #!rdmd import std.stdio; import std.json; import std.algorithm; void main() { auto ls = File("../languages.json","r").byLineCopy().joiner.parseJSON(); } ``` Error:

Re: static array is no range?

2015-09-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Sunday, 6 September 2015 at 00:25:10 UTC, cym13 wrote: Yes, static arrays aren't ranges. The main reason is that static arrays are value type (ie: you copy them arround when passing them to functions which usually has a huge cost) where ranges are reference type (no copy, lighter, not

Re: Regression?

2015-09-07 Thread Sebastiaan Koppe via Digitalmars-d-learn
Fixed it by changing into: ``` import std.conv : text; string json = File("../languages.json","r").byLineCopy().joiner.text; auto ls = json.parseJSON(); ```

Re: Regression?

2015-09-08 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 8 September 2015 at 07:12:52 UTC, FreeSlave wrote: On Tuesday, 8 September 2015 at 04:04:16 UTC, Sebastiaan Koppe wrote: Fixed it by changing into: ``` import std.conv : text; string json = File("../languages.json","r").byLineCopy().joiner.text; auto ls =

Re: What is "FilterResult" type?

2015-09-09 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 9 September 2015 at 07:19:06 UTC, Bahman Movaqar wrote: The only way to make it work is `.array.idup` the output of `filter`. For example: auto result = reduce!( (acc, num) => acc.filter!( fb => (fb.x < num && fb.y < num) && (fb.x * fb.y > num)

Re: using std.algorithm to find intersection of DateTime[][] arg

2015-09-09 Thread Sebastiaan Koppe via Digitalmars-d-learn
Couldn't you use setIntersection together with reduce? Doesn't seem like the most efficient solution, but its less typing and most likely will have no bugs.

Re: Adjacent Pairs Range

2015-09-15 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 14 September 2015 at 10:45:52 UTC, Per Nordlöw wrote: On Monday, 14 September 2015 at 05:37:05 UTC, Sebastiaan Koppe wrote: What about using zip and a slice? Slicing requires a RandomAccessRange (Array). This is too restrictive. We want to change operations such as adjacentTuples

Re: Adjacent Pairs Range

2015-09-13 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 12 September 2015 at 10:17:19 UTC, Nordlöw wrote: How do I most elegantly iterate all the adjacent pairs in an `InputRange` using Phobos? Something like [1,2,3,4] => [(1,2), (2,3), (3,4)] What about using zip and a slice? ``` void main() { auto a = [1,2,3,4];

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-29 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 29 September 2015 at 09:15:29 UTC, ponce wrote: On Monday, 28 September 2015 at 16:01:54 UTC, Sebastiaan Koppe wrote: I could not find out which redistributable I had to install (what version of VS did you have installed / on what version of windows are you?). I decided to install

Re: Do users need to install VS runtime redistributable if linking with Microsoft linker?

2015-09-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 28 September 2015 at 15:10:25 UTC, ponce wrote: On Tuesday, 22 September 2015 at 09:38:12 UTC, thedeemon wrote: On Monday, 21 September 2015 at 15:00:24 UTC, ponce wrote: All in the title. DMD 64-bit links with the VS linker. Do users need to install the VS redistributable

Re: Dub package with C code

2015-09-23 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 24 September 2015 at 04:17:14 UTC, Rikki Cattermole wrote: Is libxlsxwriter available in the systems package manager? Pacman says no. Let e.g. Windows users figure theirs out. libxlsxwriter is not supported on windows. Which is kind-of funny.

Re: Dub package with C code

2015-09-24 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 24 September 2015 at 08:35:40 UTC, Edwin van Leeuwen wrote: Alternatively you could use reggea to build both. I want to use dub. Simply because of code.dlang.org. Or can reggae also pull packages from there? You could try including the c source in your repo and add

Re: Maximum number of threads

2015-09-24 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 24 September 2015 at 08:55:25 UTC, Alex wrote: - on my mac I can have 2048 threads spawned at the same time - on my linux machine the maximum number is 32192. The numbers are quite fixed, however there were some small fluctuations on the linux machine. I only know of `cat

Re: Dub package with C code

2015-09-24 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 24 September 2015 at 06:00:50 UTC, Rikki Cattermole wrote: On 24/09/15 5:51 PM, Sebastiaan Koppe wrote: On Thursday, 24 September 2015 at 04:17:14 UTC, Rikki Cattermole wrote: Is libxlsxwriter available in the systems package manager? Pacman says no. Let e.g. Windows users

Re: Dub package with C code

2015-09-24 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 24 September 2015 at 18:19:49 UTC, Laeeth Isharc wrote: nice work! To be honest it took me 2 hours, starting from git clone worth a little blog post on the experience so others can be inspired by and benefit from yours? I would be happy to write something. Any particular blog

Re: Dub package with C code

2015-09-24 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 24 September 2015 at 12:55:12 UTC, Adam D. Ruppe wrote: On Thursday, 24 September 2015 at 06:21:02 UTC, Sebastiaan Koppe wrote: Because I want to focus on the product I am building right now, not on side-projects. We should write a C to D converter. We have htod but I'm talking

Dub package with C code

2015-09-23 Thread Sebastiaan Koppe via Digitalmars-d-learn
I have just created bindings for libxlsxwriter, an c library for creating excel files. Used the htod tool to do most of the work, and only had to adjust some things - mainly because libxlsxwriter uses data structures written in macro's. Right now I am making a dub package and I would like

Re: Dub package with C code

2015-09-24 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Friday, 25 September 2015 at 01:36:11 UTC, Atila Neves wrote: On Thursday, 24 September 2015 at 11:38:08 UTC, Sebastiaan Koppe wrote: Or can reggae also pull packages from there? Yes. That is nice. I look at reggae once or twice. It looked like a lot of bootstrapping vs. `dub init &&

Re: Dub package with C code

2015-09-25 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Friday, 25 September 2015 at 06:04:09 UTC, Laeeth Isharc wrote: Blog platform - I guess nothing wrong with wordpress etc. I am between platforms right now. I just don't want to deal with wordpress any more, and haven't yet picked something I like better. Something like Nikola and

Re: Reset all Members of a Aggregate Instance

2015-12-03 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 3 December 2015 at 21:13:59 UTC, Nordlöw wrote: Need to assert that not a function and mutability (std.traits.isMutable) Yeah you need to do that.

Re: Reset all Members of a Aggregate Instance

2015-12-03 Thread Sebastiaan Koppe via Digitalmars-d-learn
Haven't compiled but it should look something like this: foreach(member; __traits(allMembers, typeof(c))) __traits(getMember, c, member) = typeof(__traits(getMember, c, member)).init;

Re: Multithreaded HTTP Download

2015-11-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 28 November 2015 at 10:46:11 UTC, tcak wrote: The only case that would make sense is if the server limits the upload speed of each TCP socket. Unless you are in this position, I do not expect to see any difference by opening multiple sockets and requesting different parts of same

Re: Multithreaded HTTP Download

2015-11-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 28 November 2015 at 06:40:49 UTC, Mike McKee wrote: How could I achieve something like that in D? (Note, I'm using OSX.) I did it with vibe.d and http byte ranges. In general I'm trying to see if I can make a command line zip file downloader that downloads faster than Curl for

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 28 November 2015 at 19:05:59 UTC, Suliman wrote: And also I can't understand difference between HTTPClientRequest and HTTPServerRequest If the application (vibe.d) makes a request, it is the client. If the request is made to your application, it is the server. In your case your

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 28 November 2015 at 19:10:17 UTC, Suliman wrote: void action(HTTPServerRequest req, HTTPServerResponse res) { } Here is function what have two call-backs. When it's get request it's work as server, when it's send response it's work like client or I have wrong logic? Wrong

Re: Can't understand how to do server response with vibed

2015-11-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 28 November 2015 at 18:51:57 UTC, Suliman wrote: Eghm, sorry. Not req, but res, but again errr: void action(HTTPServerRequest req, HTTPServerResponse res) { writeln(req.writeJsonBody); } What you want is `req.json`. Make sure that the call from angular sets the Content-Type

Re: Can't understand how to do server response with vibed

2015-11-30 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Sunday, 29 November 2015 at 07:37:56 UTC, Suliman wrote: On Saturday, 28 November 2015 at 23:21:21 UTC, Sebastiaan Koppe wrote: On Saturday, 28 November 2015 at 19:05:59 UTC, Suliman wrote: And also I can't understand difference between HTTPClientRequest and HTTPServerRequest If the

Re: vibe.d-example illustrating Dynamic Textual Web-Interface

2015-11-30 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 30 November 2015 at 10:08:17 UTC, Nordlöw wrote: Can somebody please show a enlightening example of, so called, "revamp of the REST interface generator" added to release 0.7.26 at: http://vibed.org/blog/posts/vibe-release-0.7.26 I want to use vibe.d to add a modern dynamic

Re: vibe.d-example illustrating Dynamic Textual Web-Interface

2015-11-30 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 30 November 2015 at 20:23:48 UTC, David DeWitt wrote: Have you looked at Redux and Webpack? I am working on a Redux example and we have switched to Webpack and Redux at work and it is nice. I know about both yes. Webpack would probably beat browserify, but I haven't gotten the

Re: vibe.d-example illustrating Dynamic Textual Web-Interface

2015-12-01 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 1 December 2015 at 07:04:25 UTC, Sönke Ludwig wrote: Am 30.11.2015 um 11:08 schrieb Nordlöw: Does anybody have a similar vibe.d-project to be inspired from, in this regard? This would be more targeted to the web interface generator (vibe.web.web), which is not affected by the

Re: Is this a feature?

2016-01-21 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 21 January 2016 at 14:39:43 UTC, Adam D. Ruppe wrote: On Thursday, 21 January 2016 at 14:35:09 UTC, Sebastiaan Koppe wrote: static if (!is(SomethingUndefined!moreUndefined[0] : UndefinedThing)) Yes, the is expression returns false for undefined things because they aren't types.

Is this a feature?

2016-01-21 Thread Sebastiaan Koppe via Digitalmars-d-learn
module undefined; unittest { static if (!is(SomethingUndefined!moreUndefined[0] : UndefinedThing)) { pragma(msg,"This will compile just fine!"); } }

Re: htod question

2016-01-23 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Friday, 22 January 2016 at 01:04:50 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 01:03:09 UTC, Dibyendu Majumdar wrote: On Friday, 22 January 2016 at 00:52:59 UTC, W.J. wrote: Counter question: What's so bad about the D std library ? I am trying to create bindings for

Coverage

2016-02-16 Thread Sebastiaan Koppe via Digitalmars-d-learn
I currently run dmd's coverage on my unittests. But now I also want to execute my program with different inputs and then merge all that coverage info from each run. Any chance there is something for that?

Re: Coverage

2016-02-16 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 16 February 2016 at 12:35:38 UTC, Leandro Motta Barros wrote: You probably already though of it, but: can't you create a unittest that calls your code as many times as desired, passing different input each time? That is a viable option yes. I will probably end up doing it like

Re: Dub and unit-threaded import problem

2016-03-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 5 March 2016 at 15:05:50 UTC, Casey wrote: { "name": "unittest", "preBuildCommands": [ "dub run unit-threaded -c gen_ut_main -- -f bin/ut.d" ], "mainSourceFile": "bin/ut.d", "excludedSourceFiles": ["source/app.d"], "dependences": {

Re: How to make http requests to unix socket?

2017-08-12 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Friday, 11 August 2017 at 18:39:54 UTC, dvnguyen wrote: How to make http requests to unix socket? For example, in Docker engine api, curl --unix-socket /var/run/docker.sock http:/v1.24/containers/json I made a pull request a year ago or so to have vibe-d's requestHttp to support unix

Re: Idiomatic way of writing nested loops?

2017-07-17 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 17 July 2017 at 11:07:35 UTC, Anton Fediushin wrote: Hello! What is the best way of rewriting this code in idiomatic D manner? https://dlang.org/phobos/std_algorithm_setops.html#.cartesianProduct

Re: Idiomatic way of writing nested loops?

2017-07-17 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 17 July 2017 at 11:55:47 UTC, Anton Fediushin wrote: Thank you! I knew it is in the library! So, `parallel` will work just fine with this function, isn't it? Yes

Re: Need simple sound

2017-07-07 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 6 July 2017 at 20:36:08 UTC, FoxyBrown wrote: Heres a better version that automatically generates a class wrapping the portaudio.dll. Need portaudio.di(possibly renamed to portaudio.d and imported). Still same problem as original though. While you are at it. Please also write

Re: Need simple sound

2017-07-04 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 3 July 2017 at 08:55:20 UTC, Martin Tschierschke wrote: Hello for a simple game I would like to add some very simple sound, not much different than the beeps of "PAC Man". Is there anything I can use for this? Portaudio is simple as well. And nice cross platform.

Re: Need simple sound

2017-07-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 09:43:05 UTC, Martin Tschierschke wrote: On Wednesday, 5 July 2017 at 07:21:45 UTC, Sebastiaan Koppe wrote: On Wednesday, 5 July 2017 at 05:34:37 UTC, FoxyBrown wrote: On Tuesday, 4 July 2017 at 20:37:44 UTC, Sebastiaan Koppe wrote: Portaudio is simple as well.

Re: Need simple sound

2017-07-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 05:34:37 UTC, FoxyBrown wrote: On Tuesday, 4 July 2017 at 20:37:44 UTC, Sebastiaan Koppe wrote: Portaudio is simple as well. And nice cross platform. are there any bindings? Sure, see http://code.dlang.org/packages/portaudio

Re: unittest-cov - results?

2017-07-06 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 5 July 2017 at 19:01:06 UTC, Jonathan M Davis wrote: I ran into a bug in dub not all that long ago where the tests in the module with main in it weren't actually being run even though the other tests were. (which reminds me, I should verify that again and report it). - Jonathan

Re: Need simple sound

2017-07-06 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 6 July 2017 at 10:47:53 UTC, FoxyBrown wrote: On Wednesday, 5 July 2017 at 07:21:45 UTC, Sebastiaan Koppe wrote: On Wednesday, 5 July 2017 at 05:34:37 UTC, FoxyBrown wrote: On Tuesday, 4 July 2017 at 20:37:44 UTC, Sebastiaan Koppe wrote: Portaudio is simple as well. And nice

Re: Need simple sound

2017-07-06 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 6 July 2017 at 13:28:26 UTC, FoxyBrown wrote: On Wednesday, 5 July 2017 at 07:21:45 UTC, Sebastiaan Koppe wrote: Sure, see http://code.dlang.org/packages/portaudio So, after a bit of work I can get port audio to work but the callback never seems to be called(no audio, never hits

Re: Deprecated std.c.*.socket and missing replacement

2017-06-27 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 27 June 2017 at 17:58:29 UTC, Jonathan M Davis wrote: Why would you need to remove anything from Phobos? The enum in question is in a deprecated module. All that should need to happen is that the enum be added to the appropriate module in druntime, and then any code that uses it

Re: Deprecated std.c.*.socket and missing replacement

2017-06-27 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 27 June 2017 at 19:22:02 UTC, Steven Schveighoffer wrote: Just delete the duplicate symbol, and add public imports of the other module symbols. e.g.: public import core.sys.posix.netinet.in_: IP_ADD_MEMBERSHIP; -Steve Great. Will do.

Re: Deprecated std.c.*.socket and missing replacement

2017-06-27 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 27 June 2017 at 11:16:17 UTC, Jonathan M Davis wrote: Create a PR to add it to druntime and/or define it in your own code. - Jonathan M Davis Creating a PR sounds reasonable. But I would have to create one PR to remove them from phobos and one PR to add them to druntime, right?

Deprecated std.c.*.socket and missing replacement

2017-06-27 Thread Sebastiaan Koppe via Digitalmars-d-learn
I am building a multicast application, and I am using the std.c.*.socket modules to provide the definition of the IP_ADD_MEMBERSHIP constant. These modules are marked as deprecated telling me to look in core.sys.posix.* instead. I grepped the complete sourcetree, but nowhere is the

Re: Is there any threadsafe queue?

2017-09-14 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 13 September 2017 at 22:54:06 UTC, Seb wrote: https://code.dlang.org/packages/lock-free That package has a single-reader single-writer queue, exactly what the OP asked for.

Re: Cannot make LDC use LTO when called via DUB

2017-09-25 Thread Sebastiaan Koppe via Digitalmars-d-learn
Neither dflags-dmd "-xxx" dflags-posix-dmd "-xxx" dflags-linux-dmd "-xxx" has any effect on my build (in dub.sdl). I didn't know dflags-* was a thing, and I can't find it in docs either. Maybe you are looking for dflags "..." platform="..."

Re: ?? How to subscribe to Multicast Broadcasts ??

2018-08-18 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 13 August 2018 at 01:12:16 UTC, Joe wrote: Please Please Please Help, I am desperate! Many Thanks in Advance for your time & attention, -joe I implemented multicast support in vibe.d, I hope looking at the source can help you:

UDA on double nested struct

2018-08-20 Thread Sebastiaan Koppe via Digitalmars-d-learn
Hey, I am trying to get UDAs from a doubly nested struct, to no avail: code --- import std.traits : hasUDA; enum hover; struct Style { struct Root { auto margin = "10px"; auto backgroundColor = "white"; @hover struct Hover { auto backgroundColor = "gray"; } } }

Re: UDA on double nested struct

2018-08-20 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Monday, 20 August 2018 at 16:27:55 UTC, Basile B. wrote: Hello, it works fine here. Maybe there was another error that you removed when you have minimized the example. See https://run.dlang.io/is/ZrW7kI, that says that the example works since 2.068.2. Although that are are possibility that

Re: tupleof function parameters?

2018-08-28 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Tuesday, 28 August 2018 at 06:11:35 UTC, Jon Degenhardt wrote: The goal is to write the argument list once and use it to create both the function and the Tuple alias. That way I could create a large number of these function / arglist tuple pairs with less brittleness. --Jon I would

Re: Need help with calling a list of functions

2018-11-04 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Sunday, 4 November 2018 at 01:17:01 UTC, Luigi wrote: I need to call a function that can create a function from an array of functions and calls them in reverse order. I am learning D any help would be That sounds a lot like std.functional.compose

Re: How do I use null in a struct?

2018-11-10 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Saturday, 10 November 2018 at 19:42:47 UTC, Václav Kozák wrote: I'm making a Rest API with vibe.d and I have a struct User. Sometimes I need to return only a few of the fields. So for example: return User(1, null, "John", null, null, ...); If I do this, an error occurs: cannot implicitly

Re: Template/mixin ideas?

2018-10-03 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 11:01:53 UTC, Chris Katko wrote: I've got this simple task but I'm trying to perfect it as best I can to learn something in the process. I have Linux terminal ASCII codes for coloring terminal output. string red(string) { /* ... */ } "Hello world".red =>

Re: Template/mixin ideas?

2018-10-05 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Thursday, 4 October 2018 at 01:12:04 UTC, Chris Katko wrote: The mixin part wouldn't be slowed by strings, right? So the "slowness" is the invokation part which changes strings and forces GC allocations, I guess? Yep, that is right. What's the alternative to using strings... for strings?

Re: Template return type?

2018-10-03 Thread Sebastiaan Koppe via Digitalmars-d-learn
On Wednesday, 3 October 2018 at 10:01:02 UTC, Andrea Fontana wrote: On Wednesday, 3 October 2018 at 09:37:29 UTC, JN wrote: int i = returnDefault!int(); obviously works, but the point is I would like to skip the explicit type. See:

Re: vibe.d error