Re: Getting a String Literal From an Aliased Template Mixin Parameter
On Thursday, 15 September 2016 at 01:40:50 UTC, Anonymouse wrote: You mean, the literal string name of the original symbol you passed as an alias? If so then you want the .stringof property. void main () { int first; bool second; string third; mixin Foo!(first, second, third); } mixin template Foo(alias abc, alias def, alias ghi) { static assert(abc.stringof == "first"); static assert(def.stringof == "second"); static assert(ghi.stringof == "third"); } Aha! Yes, that's exactly what I was looking for! Thanks!
Re: Using OpenGL
On Wednesday, 14 September 2016 at 16:49:51 UTC, Darren wrote: While googling, the idea seemed to be to create and SDL_Surface* and pass that (or surface.pixels) as the last argument for glTexImage2D. Didn't work for me, however. Does anyone have any tips? I'm driving blind here without any of your code to see, but here's some general advice. The last three arguments to glTexImage2D [1] are what you use to describe the image data you are sending to it (aside from 'width' & 'height', which also set the size of the texture being created). `format` needs to match the format of your image. For most simple things you do with OpenGL, that's going to be GL_RGB or GL_RGBA. If you don't know the format of your image, you can get it from the SDL_PixelFormatEnum value [2] in surface.format.format. Then you'll just need to send the corresponding GL enum to glTexImage2D. Though, be aware that the way SDL and OGL treat color formats may not always correspond in the way you think they should [3]. `type` is almost always going to be GL_UNSIGNED_BYTE. I don't know that SDL_image supports anything else, like floating point formats, anyway. `data` needs to be a pointer to the pixel data and nothing else (never SDL_Surface!), so in this case surface.pixels is correct. If you are getting a crash, check the return of any of the image loading functions you call to make sure the load was successful. That's the first place I'd check. [1] https://www.opengl.org/sdk/docs/man/html/glTexImage2D.xhtml [2] https://wiki.libsdl.org/SDL_PixelFormatEnum [3] https://bugzilla.libsdl.org/show_bug.cgi?id=2111
Re: Getting a String Literal From an Aliased Template Mixin Parameter
On Thursday, 15 September 2016 at 00:15:42 UTC, jsako wrote: I was making a quick mocking infrastructure for internal mocks so I wouldn't have to pass in objects to constructors all the time and came up with this: [...] This works great as long as there is only one mock object. I thought about using string mixins to generate the properties on a per-variable basis, but the problem is that I can't figure out how to get the string of the variable name from the aliased template mixin parameter. Is there a way to do this? If not, I'll have to pass in the strings of the variables seperately (as in: mixin internalMockRig!(thing, "thing", testThing, "testThing", testThingMock, "testThingMock"); ), but that seems inelegant (and a bit error prone). You mean, the literal string name of the original symbol you passed as an alias? If so then you want the .stringof property. void main () { int first; bool second; string third; mixin Foo!(first, second, third); } mixin template Foo(alias abc, alias def, alias ghi) { static assert(abc.stringof == "first"); static assert(def.stringof == "second"); static assert(ghi.stringof == "third"); }
Getting a String Literal From an Aliased Template Mixin Parameter
I was making a quick mocking infrastructure for internal mocks so I wouldn't have to pass in objects to constructors all the time and came up with this: [code] mixin template internalMockRig(alias _var, string _varName, alias _varStandard, alias _varMock) { version(unittest) { @property bool internalMockSetting() { return _useInternalMocks; } @property useInternalMocks(bool uim) { // Are we changing the mock type? if (uim != _useInternalMocks) { _useInternalMocks = uim; if(_useInternalMocks) { _var = new _varMock; } else { _var = new _varStandard; } } } private: bool _useInternalMocks = false; } } [/code] Then in the object: [code] class usingTestThing { testThing thing; mixin internalMockRig!(thing, testThing, testThingMock); this() { thing = new testThing; } } [/code] This works great as long as there is only one mock object. I thought about using string mixins to generate the properties on a per-variable basis, but the problem is that I can't figure out how to get the string of the variable name from the aliased template mixin parameter. Is there a way to do this? If not, I'll have to pass in the strings of the variables seperately (as in: mixin internalMockRig!(thing, "thing", testThing, "testThing", testThingMock, "testThingMock"); ), but that seems inelegant (and a bit error prone).
Re: Compiling vibe.d application for Amazon ec2 instance
On Wednesday, 14 September 2016 at 12:13:58 UTC, Seb wrote: You should try -static in ldc, it's works like a dream for me :) Yep, LDC supports fully static linking on Linux (and is currently the only compiler to do so). — David
Re: vibe.d maxRequestSize
On 9/14/16 9:58 AM, Chris wrote: The vibe.d server rejects `XMLHttpRequest`s that are too long (in the eyes of the server). In the docs it says "maxRequestSize ulong Maximum number of transferred bytes per request after which the connection is closed with [sic!]" However, when you go to http://vibed.org/api/vibe.http.server/HTTPServerSettings.maxRequestSize it says "Maximum number of transferred bytes per request after which the connection is closed with an error; not supported yet" "not supported yet" and I think it is not supported yet. Can I still change the server settings so that it accepts longer query strings? Atm, the server rejects strings that are > ~2,500 characters, which is not much. Hm.. I have adjusted this in my project, and it works (set to 50M). Needed it for uploading large images. Using version 0.7.29 -Steve
Re: Can vibe d leverage existing web technologies?
On Wednesday, 14 September 2016 at 04:22:02 UTC, Brad Anderson wrote: On Tuesday, 13 September 2016 at 23:45:18 UTC, Intersteller wrote: vibe.d does not have much lateral support as the most commons web technologies do. Can vibe.d leverage pre-existing techs such as php, ruby/rails, etc? Starting from scratch and having to build a robust and secure framework is really not the way to go. Sure. Just use res.write(executeShell(["php", "-f", "somephpscript.php"]).output); or something like that. But seriously, you probably don't want to do that. It's like asking if ruby on rails can leverage php. Sure, they can communicate over HTTP or whatever else they support but trying to execute PHP from within Rails or vice versa just isn't really all that beneficial. It is if you want to use pre-existing technologies. There are tons of php frameworks for doing things. Virtually nothing exists for vibe.d. e.g., any e-commerce stuff for vibe.d? I turned up one outdated, unfinished, and unmaintained package for d. There are hundreds, if not thousands for php. So are you suggesting I do not use vibe.d? It's not like ruby/rails because ruby/rails also has a larger set of technologies. You are comparing apples to oranges. vibe.d has nearly 0 while the others have nearly an infinite. If vibe.d had nearly an infinite I would be asking this question. Hopefully your solution works. Thanks.
Re: Using OpenGL
Kind of resurrecting this thread; hope that's okay. I'm working through this tutorial: http://www.learnopengl.com/#!Getting-started/Textures It uses SOIL to load images, but I haven't seen any SOIL bindings in dub. I tried using SDL and SDL_Image but when the program ran it just crashed. I guess I was doing something wrong. While googling, the idea seemed to be to create and SDL_Surface* and pass that (or surface.pixels) as the last argument for glTexImage2D. Didn't work for me, however. Does anyone have any tips?
Re: vibe.d PaaS
On Wednesday, 14 September 2016 at 16:03:50 UTC, Guillaume Piolat wrote: On Wednesday, 14 September 2016 at 10:56:57 UTC, llaine wrote: No PaaS service, but you can pretty simply use Heroku to deploy any vibe.d application. Check the tour.dlang.io http://tour.dlang.io/tour/en/vibed/deploy-on-heroku where everything is explained :) Thanks! I've had success connecting vibe-d and heroku hosted postgresql dbs too :)
Re: vibe.d PaaS
On Wednesday, 14 September 2016 at 10:56:57 UTC, llaine wrote: No PaaS service, but you can pretty simply use Heroku to deploy any vibe.d application. Check the tour.dlang.io http://tour.dlang.io/tour/en/vibed/deploy-on-heroku where everything is explained :) Thanks!
vibe.d maxRequestSize
The vibe.d server rejects `XMLHttpRequest`s that are too long (in the eyes of the server). In the docs it says "maxRequestSize ulong Maximum number of transferred bytes per request after which the connection is closed with [sic!]" However, when you go to http://vibed.org/api/vibe.http.server/HTTPServerSettings.maxRequestSize it says "Maximum number of transferred bytes per request after which the connection is closed with an error; not supported yet" "not supported yet" and I think it is not supported yet. Can I still change the server settings so that it accepts longer query strings? Atm, the server rejects strings that are > ~2,500 characters, which is not much.
Re: Binary heap: obtain a _reference_ to the front of the heap
On Tuesday, 13 September 2016 at 08:55:15 UTC, Nicholas Wilson wrote: On Tuesday, 13 September 2016 at 08:19:04 UTC, Johan Engelen wrote: In the binary heap documentation, I read that `BinaryHeap.front()` "Returns a copy of the front of the heap". [1] Is there no function to access the front of the heap without a copy? (micro-optimization) Thanks, Johan [1] https://dlang.org/phobos/std_container_binaryheap.html#.BinaryHeap.front What does foreach(ref e; bh) { //... } do? It copies the front of the heap on every iteration.
Re: Compiling vibe.d application for Amazon ec2 instance
On Monday, 12 September 2016 at 02:14:08 UTC, Jonathan M Davis wrote: On Sunday, September 11, 2016 23:12:15 crimaniak via Digitalmars-d-learn wrote: [...] I've never used EC2, so I don't know what it would take to be able to build in the same environment locally (though I would certainly think that there would be a way do to so, and I would assume that Amazon's documentation talks about it somewhere). However, you can try just grabbing the .zip file for dmd and putting that on your EC2 instance and using that to build your program there - especially if you're in a hurry. [...] You should try -static in ldc, it's works like a dream for me :)
Re: vibe.d PaaS
On Wednesday, 14 September 2016 at 09:40:47 UTC, wobbles wrote: On Wednesday, 14 September 2016 at 09:01:11 UTC, Guillaume Piolat wrote: Is there vibe.d hosting sold anywhere? Not that I know, but any VPS you rent would be capable of hosting it. I guess you don't want to deal with all of the other services you'd need? (nginx / security / dbs etc etc ?) That's what I do currently, but I'm no sysadmin and something that would bundle postgres, vibe.d and SSL for the lazy would be nice. Though the market for it is probably small.
Re: vibe.d PaaS
On Wednesday, 14 September 2016 at 09:40:47 UTC, wobbles wrote: On Wednesday, 14 September 2016 at 09:01:11 UTC, Guillaume Piolat wrote: Is there vibe.d hosting sold anywhere? Not that I know, but any VPS you rent would be capable of hosting it. I guess you don't want to deal with all of the other services you'd need? (nginx / security / dbs etc etc ?) No PaaS service, but you can pretty simply use Heroku to deploy any vibe.d application. Check the tour.dlang.io http://tour.dlang.io/tour/en/vibed/deploy-on-heroku where everything is explained :)
Re: vibe.d PaaS
On Wednesday, 14 September 2016 at 09:01:11 UTC, Guillaume Piolat wrote: Is there vibe.d hosting sold anywhere? Not that I know, but any VPS you rent would be capable of hosting it. I guess you don't want to deal with all of the other services you'd need? (nginx / security / dbs etc etc ?)
vibe.d PaaS
Is there vibe.d hosting sold anywhere?