Dependency injection pattern

2018-05-13 Thread Suliman via Digitalmars-d-learn
Could anybody give small example of Dependency injection pattern? I googled about it, but found only C# examples and I am not quite sure how to use them. Also I would like get some explanation/comments for code.

How to use LLD linker?

2018-06-30 Thread Suliman via Digitalmars-d-learn
Correct me if I am wrong, but I have read news that dmd now can be used without C++ Build Tools. I trying to build simple project. And getting Error: Warning: no Visual C++ installation detected OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. ht

Can't build app. VS Build Tools is installed

2018-06-30 Thread Suliman via Digitalmars-d-learn
I am trying to build simple app. And getting next error: OPTLINK (R) for Win32 Release 8.00.17 Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html .dub\build\application-debug-windows-x86-dmd_2081-AC4AEBC828F1A14C3806E4E63B3CEEF3\app.obj(app) E

Re: How to use LLD linker?

2018-07-06 Thread Suliman via Digitalmars-d-learn
Well I just installed the VS 2017 to try the ldc and get (maybe) the same error. dub run --config=application --arch=x86_64 --build=debug --compiler=ldc2 Performing "debug" build using ldc2 for x86_64. lib ~master: building configuration "application"... OPTLINK (R) for Win32 Release 8.00.17

Is it's correct to say that ALL types that can grow are place on heap?

2018-09-08 Thread Suliman via Digitalmars-d-learn
Is it's correct to say that ALL types that can grow are place on heap and types that not growing (int, char, pointer) are place on stack? Or there is some exceptions? Is there any tools that can visualize place of data in memory?

Is there any working SQLite driver for windows?

2018-12-26 Thread Suliman via Digitalmars-d-learn
Yesterday I tried several sqlite drivers and all of them have some issue that make it's build on Windows impossible. Few examples https://github.com/huntlabs/hunt-database/issues/24 https://github.com/biozic/d2sqlite3/issues/51

Re: Is there any working SQLite driver for windows?

2018-12-26 Thread Suliman via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 11:06:02 UTC, Andre Pany wrote: On Wednesday, 26 December 2018 at 08:19:03 UTC, Suliman wrote: Yesterday I tried several sqlite drivers and all of them have some issue that make it's build on Windows impossible. Few examples https://github.com/huntlabs/hunt-d

Re: Is there any working SQLite driver for windows?

2018-12-26 Thread Suliman via Digitalmars-d-learn
On Wednesday, 26 December 2018 at 12:13:27 UTC, Suliman wrote: On Wednesday, 26 December 2018 at 11:06:02 UTC, Andre Pany wrote: On Wednesday, 26 December 2018 at 08:19:03 UTC, Suliman wrote: Yesterday I tried several sqlite drivers and all of them have some issue that make it's build on Window

Am I missing with ref in this code?

2019-01-24 Thread Suliman via Digitalmars-d-learn
I am doing very small link-checker. Here is' code https://run.dlang.io/is/p8whrA I am expecting that on line: writefln("url: %s, status: %s", url.url, url.status); I will print link and it's status. But I am getting only: url: http://127.0.0.1:8081/hck, status: url: http://127.0.0.1:8081/hck2,

Re: Am I missing with ref in this code?

2019-01-24 Thread Suliman via Digitalmars-d-learn
It's because runWorkerTask internally passes its arguments along to the function by value: https://github.com/vibe-d/vibe.d/blob/master/core/vibe/core/core.d#L364 The workaround is to pass a pointer instead: void getServiceStatus(MyUrl* url) { // ... } // ... runWorke

Re: Am I missing with ref in this code?

2019-01-24 Thread Suliman via Digitalmars-d-learn
On Thursday, 24 January 2019 at 22:02:36 UTC, bauss wrote: On Thursday, 24 January 2019 at 21:25:45 UTC, Paul Backus wrote: So, I'm not sure what the best solution here is. The best solution is just to pass a copy since there's no absolute need for a reference to be passed. But if I will pa

Re: Am I missing with ref in this code?

2019-01-25 Thread Suliman via Digitalmars-d-learn
Do I need in my code `ref`s ? https://run.dlang.io/is/8dtkC7 Or if vibed doing copy under the hood `ref`s useless?

Can't build vibed:tls project

2019-01-28 Thread Suliman via Digitalmars-d-learn
If I am specifying (sic! TLS): dependency "vibe-d:tls" version="0.8.4" in my dub.sdl I am getting error when building simple project: module `vibe` is in file 'vibe\vibe.d' which cannot be read But I need to get vibed build with OpenSSL support

Vibed + OpenSSL on Windows 10?

2019-01-28 Thread Suliman via Digitalmars-d-learn
Does anybody have success with using vibed 0.8.4 with OpenSSL 1.0/1.1 on Windows? I tried all possible solutions without any result. I am getting linking error: Copyright (C) Digital Mars 1989-2013 All rights reserved. http://www.digitalmars.com/ctg/optlink.html C:\Users\bubnenkov\AppData\Loc

Re: Vibed + OpenSSL on Windows 10?

2019-01-29 Thread Suliman via Digitalmars-d-learn
Always compile vibe.d with mscoff Could you show command to compile with mscoff?

Re: Vibed + OpenSSL on Windows 10?

2019-01-29 Thread Suliman via Digitalmars-d-learn
On Tuesday, 29 January 2019 at 10:01:04 UTC, Suliman wrote: Always compile vibe.d with mscoff Could you show command to compile with mscoff? I am not sure that all works fine, but at last I do not have linking error. I have add to dub.sdl ext string: "dflags-windows-x86": ["-m32mscoff"]

Re: Vibed + OpenSSL on Windows 10?

2019-01-29 Thread Suliman via Digitalmars-d-learn
On Tuesday, 29 January 2019 at 10:06:43 UTC, Suliman wrote: On Tuesday, 29 January 2019 at 10:01:04 UTC, Suliman wrote: Always compile vibe.d with mscoff Could you show command to compile with mscoff? I am not sure that all works fine, but at last I do not have linking error. I have add to

How to add authentificaion method to request?

2017-07-11 Thread Suliman via Digitalmars-d-learn
I am using dlang-requests. I need authentificate on https://scihub.copernicus.eu/dhus/login and than do some data-parsing. MultipartForm form; form.add(formData("login_username", "Suliman")); form.add(formData("login_password", "123")); // changed auto content = postContent("ht

Re: How to add authentificaion method to request?

2017-07-12 Thread Suliman via Digitalmars-d-learn
Compiler require libssl32.dll for run dlang-request based app. Where I can get it? I installed, OpenSSL, but can't find this lib in C:\OpenSSL-Win64

Need help to get OpenSSL 64 work on Windows x64 | I hate D's GC!

2017-07-14 Thread Suliman via Digitalmars-d-learn
It's look that GC in D is really suxx. There is already second toy-project where I am getting stuck on Windows with D for last 3 month. I'm using 32-bit build, because I can't understand which libs I should use to get OpenSSL 64 bit work with dlang-request. 32-bit version compile and works f

Re: Need help to get OpenSSL 64 work on Windows x64 | I hate D's GC!

2017-07-14 Thread Suliman via Digitalmars-d-learn
On Friday, 14 July 2017 at 14:50:04 UTC, bauss wrote: On Friday, 14 July 2017 at 13:16:17 UTC, Suliman wrote: It's look that GC in D is really suxx. There is already second toy-project where I am getting stuck on Windows with D for last 3 month. I'm using 32-bit build, because I can't underst

How to replace pairs tags with regexp

2017-07-20 Thread Suliman via Digitalmars-d-learn
I have got next code: import std.stdio; import std.regex; import std.file; void main() { auto text = readText("book.txt"); auto inlineCodeBlock = regex("`([^`\n]+)`"); auto bigCodeBlock = regex(r"`{3}[\s\S]*?`{3}"); foreach(t; text.matchAll(bigCo

Re: How to replace pairs tags with regexp

2017-07-20 Thread Suliman via Digitalmars-d-learn
Question above do not actual now. Now I have got next problem. import std.stdio; import std.regex; import std.file; void main() { auto text = "#Header my header text ##SubHeader my sub header text ###Sub3Header my sub 3 text #Header2 my header2 text"; auto

Re: How to replace pairs tags with regexp

2017-07-20 Thread Suliman via Digitalmars-d-learn
Ali Thanks! I opened answer form before you answered me!

Re: How to replace pairs tags with regexp

2017-07-20 Thread Suliman via Digitalmars-d-learn
There reason of issue above is spaces before "#".

Re: How to replace pairs tags with regexp

2017-07-21 Thread Suliman via Digitalmars-d-learn
On Friday, 21 July 2017 at 06:19:43 UTC, Suliman wrote: There reason of issue above is spaces before "#". What wrong with next regex https://dpaste.dzfl.pl/024a47ed2a56 I expect that it will select: #Header my header text ##SubHeader my sub header text Because: ^#{3}

Re: How to replace pairs tags with regexp

2017-07-21 Thread Suliman via Digitalmars-d-learn
On Friday, 21 July 2017 at 07:30:07 UTC, Antonio Corbi wrote: On Friday, 21 July 2017 at 07:08:34 UTC, Suliman wrote: On Friday, 21 July 2017 at 06:19:43 UTC, Suliman wrote: There reason of issue above is spaces before "#". What wrong with next regex https://dpaste.dzfl.pl/024a47ed2a56 I exp

Why D have two function contains and canFind?

2017-07-24 Thread Suliman via Digitalmars-d-learn
Why D have two function `contains` and `canFind` if C# have only contains and it's enough?

Is it's possible to make modular pug template in vibed?

2017-08-08 Thread Suliman via Digitalmars-d-learn
For example I am making simple site with header and footer. header and footer will be same for all pages. I do not want to do copy-paste it in every page. I want write it's once and than simpy import in every page. Is it's possible to do with vibed?

Re: Is it's possible to make modular pug template in vibed?

2017-08-08 Thread Suliman via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 11:55:09 UTC, Suliman wrote: For example I am making simple site with header and footer. header and footer will be same for all pages. I do not want to do copy-paste it in every page. I want write it's once and than simpy import in every page. Is it's possible to do

Re: Is it's possible to make modular pug template in vibed?

2017-08-08 Thread Suliman via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 11:59:38 UTC, Suliman wrote: On Tuesday, 8 August 2017 at 11:55:09 UTC, Suliman wrote: For example I am making simple site with header and footer. header and footer will be same for all pages. I do not want to do copy-paste it in every page. I want write it's once a

Re: Is it's possible to make modular pug template in vibed?

2017-08-08 Thread Suliman via Digitalmars-d-learn
Yes, thanks what: extends layout mean?

Re: Is it's possible to make modular pug template in vibed?

2017-08-08 Thread Suliman via Digitalmars-d-learn
Still can't get it work. include header .MainContainer .Header .HeaderMenu .HeaderBlock a(href="/") General .HeaderBlock a(href="/FAQ") FAQ .HeaderBlock a(href="/book") Book .HeaderLoginBlock Sign in .Middle f include footer it's template is compilable,

Re: Is it's possible to make modular pug template in vibed?

2017-08-08 Thread Suliman via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 13:22:58 UTC, Steven Schveighoffer wrote: On 8/8/17 9:10 AM, Suliman wrote: Yes, thanks what: extends layout mean? It means that your final file will be layout.dt, but with the block statements replaced with the contents defined by the specific view file. Think

Re: Is it's possible to make modular pug template in vibed?

2017-08-08 Thread Suliman via Digitalmars-d-learn
Am I right understand that I can extend only one template?

Re: Is it's possible to make modular pug template in vibed?

2017-08-08 Thread Suliman via Digitalmars-d-learn
your examples generate me: DLANG.ru (c) DLANG 2017 The only one modification that I did I changes pages names: extends home

Re: Is it's possible to make modular pug template in vibed?

2017-08-09 Thread Suliman via Digitalmars-d-learn
On Tuesday, 8 August 2017 at 15:54:29 UTC, Steven Schveighoffer wrote: On 8/8/17 10:52 AM, Suliman wrote: your examples generate me: DLANG.ru (c) DLANG 2017 That's the template without the bl

If structures places data to stack why we do not getting stackoverflow on array of structures?

2017-08-16 Thread Suliman via Digitalmars-d-learn
If structures placing data on the stack why we do not getting stackoveflow while we creating array of structures? Or for example big structure. Am I right understand that structures placing data _only_ on stack? But the stack size is very limited (on Widnows it's just 1MB). So how it's work

Re: If structures places data to stack why we do not getting stackoverflow on array of structures?

2017-08-16 Thread Suliman via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 07:09:02 UTC, rikki cattermole wrote: On 16/08/2017 8:06 AM, Suliman wrote: If structures placing data on the stack why we do not getting stackoveflow while we creating array of structures? Or for example big structure. Am I right understand that structures pla

Re: If structures places data to stack why we do not getting stackoverflow on array of structures?

2017-08-16 Thread Suliman via Digitalmars-d-learn
On the heap, unless you are allocating it via e.g. alloca. If struct MyStruct { int x; int y; } MyStruct mystruct; is located on stack, why: MyStruct [] mystructs; should located on heap?

Re: If structures places data to stack why we do not getting stackoverflow on array of structures?

2017-08-16 Thread Suliman via Digitalmars-d-learn
MyStruct[] is actually a struct similar to this: struct MyStruct[] { MyStruct* ptr; size_t length; } That struct is placed on the stack, but the data it points to, via the ptr field, is heap allocated. What is struct? Just name and size?

Re: If structures places data to stack why we do not getting stackoverflow on array of structures?

2017-08-16 Thread Suliman via Digitalmars-d-learn
On Wednesday, 16 August 2017 at 13:41:29 UTC, Biotronic wrote: On Wednesday, 16 August 2017 at 12:50:07 UTC, Suliman wrote: MyStruct[] is actually a struct similar to this: struct MyStruct[] { MyStruct* ptr; size_t length; } That struct is placed on the stack, but the data it points t

vibed services stop response after several days of work

2017-09-01 Thread Suliman via Digitalmars-d-learn
I got same problem on Windows Server 2016 and on Linux Debian 8.5. I have few very simple backend based on vibed 0.8.1, compiler dmd 2.075.1. nginx servise is do port forwarding. Nothing more is used. After several days of working I am begining to get "502 Bad Gateway" error. The service is n

Re: vibed services stop response after several days of work

2017-09-01 Thread Suliman via Digitalmars-d-learn
On Friday, 1 September 2017 at 08:01:24 UTC, Suliman wrote: I got same problem on Windows Server 2016 and on Linux Debian 8.5. I have few very simple backend based on vibed 0.8.1, compiler dmd 2.075.1. nginx servise is do port forwarding. Nothing more is used. After several days of working I

Re: vibed services stop response after several days of work

2017-09-01 Thread Suliman via Digitalmars-d-learn
It's seems that it's error in libevent on Linux. I tried to add to dub.sdl: versions "libasync" and it's seems that not it's working (but I need more time to test).

How Appender calculate cash size?

2017-09-06 Thread Suliman via Digitalmars-d-learn
If I right understand Appender and ~ have buffers to minimize allocations. "Appender's local capacity storage will give you a pretty big boost" (с) Adam "Appender maintains its own array metadata locally, so it can avoid global locking for each append where capacity is non-zero." (с) Docs S

Re: DLang IDE [RU]

2017-09-07 Thread Suliman via Digitalmars-d-learn
А можно сделать как-то так, чтобы автокомплит работал сразу? Как в студии. То есть бы не приходилось ctrl+пробел нажимать.

What is top 5 patterns that you use in real life?

2017-09-09 Thread Suliman via Digitalmars-d-learn
Just interesting, what top 5 programming patterns that you use in real D projects. For example I know that Singleton is very popular pattern, but I have never used it in real project. Same I can say about dependency injection.

Re: Struct List Human

2017-09-24 Thread Suliman via Digitalmars-d-learn
On Sunday, 24 September 2017 at 14:32:14 UTC, dark777 wrote: I have the following code: https://pastebin.com/PWuaXJNp but typing my name does not go to the next line as soon as I press enter how to solve this? use writeln instead write

Why dynamic lib can't be converted to static and vise versa

2017-12-18 Thread Suliman via Digitalmars-d-learn
I understand that dll can be loaded dynamically, and static lib is allow export functions than embedded to binaries. But what difference in their structure? What stop to export needed function from dynamic lib and embed it to bin?

What principle difference between structure and Tuple?

2018-03-10 Thread Suliman via Digitalmars-d-learn
writeln(is(Tuple!(string, int) == struct)); // true What is real user case where I should use Tuple instead of Struct?

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Monday, 5 March 2012 at 15:35:59 UTC, Steven Schveighoffer wrote: On Wed, 29 Feb 2012 20:25:35 -0500, bearophile wrote: Do you know why std.array.Appender defines a "put" method instead of overloading the "~=" operator? It should (in addition to put). I see you have already filed an en

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)'

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:34:02 UTC, John Colvin wrote: On Tuesday, 13 October 2015 at 13:21:54 UTC, Suliman wrote: I tried to use map! but it's look like it do not work with string, becouse I got error: Error: no property 'map' for type 'ByLine!(char, char)' I suspect you don't have

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
something like: auto content = file.byLine.map!("start " ~ a=>a ~ " end");

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:55:07 UTC, anonymous wrote: On Tuesday 13 October 2015 15:47, Suliman wrote: something like: auto content = file.byLine.map!("start " ~ a=>a ~ " end"); That's not how it works at all. Maybe stick to the examples of whatever resource you're learning from, for

Re: Regarding std.array.Appender

2015-10-13 Thread Suliman via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 13:51:50 UTC, anonymous wrote: On Tuesday 13 October 2015 15:42, Suliman wrote: map!(a=> a~=" +") work fine, but how to add before at same time? Use ~ instead of ~=, like so: map!(a => "+" ~ a ~ "+") Thanks!

Re: Why does File.byLine() return char[] and not string

2015-10-18 Thread Suliman via Digitalmars-d-learn
On Friday, 16 October 2015 at 12:43:59 UTC, Meta wrote: On Friday, 16 October 2015 at 10:38:52 UTC, Shriramana Sharma wrote: Is there a particular reason that File.byLine() returns char[] and not string i.e. immutable(char)[]? Is it just to avoid being overly restrictive? It seems that having t

Re: Why does File.byLine() return char[] and not string

2015-10-18 Thread Suliman via Digitalmars-d-learn
On Sunday, 18 October 2015 at 15:40:09 UTC, novice2 wrote: what buffer you are talking. internal buffer. where result line resides. And what is "signal"? How it's working? just the fact for programmer, that result line can be changed by other code (by phobos library code in this case).

Re: Curl, how to recieve data.

2015-10-18 Thread Suliman via Digitalmars-d-learn
On Sunday, 18 October 2015 at 18:04:53 UTC, holo wrote: I'm trying to receive data from curl request my sample code looks like that: ... auto client = HTTP(endpoint ~ "?" ~ canonicalQueryString); client.method = HTTP.Method.get; client.addRequestHeader("x-a

Why my app require MSVCR120.dll?

2015-11-06 Thread Suliman via Digitalmars-d-learn
I wrote Application in D. That use next components: "colorize": ">=1.0.5", "ddbc": ">=0.2.11", "vibe-d": "~>0.7.26" On Windows 7 it's work fine. On Windows 10 (clean install) it's do not start and require MSVCR120.dll And I can't understand what component is pulling this lib as dependence. Wha

Re: Why my app require MSVCR120.dll?

2015-11-06 Thread Suliman via Digitalmars-d-learn
On Friday, 6 November 2015 at 13:50:56 UTC, Kagamin wrote: MSVCR is a C runtime. On Linux it will depend on a C runtime too. But which part of my App depend on C runtime?

Re: Why my app require MSVCR120.dll?

2015-11-07 Thread Suliman via Digitalmars-d-learn
On Friday, 6 November 2015 at 18:39:49 UTC, ponce wrote: On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote: I wrote Application in D. That use next components: "colorize": ">=1.0.5", "ddbc": ">=0.2.11", "vibe-d": "~>0.7.26" On Windows 7 it's work fine. On Windows 10 (clean install) it

Re: Why my app require MSVCR120.dll?

2015-11-07 Thread suliman via Digitalmars-d-learn
On Sunday, 8 November 2015 at 04:50:49 UTC, thedeemon wrote: On Saturday, 7 November 2015 at 10:03:58 UTC, Suliman wrote: I am using DMD. -m64 or -m32mscoff ? Without any keys. I use dub for building

Can't understand how to do server response with vibed

2015-11-28 Thread Suliman via Digitalmars-d-learn
Could anybody help me to understand how to complete HTTP response with vibed. I am sending POST request from AngularJS: $.post("http://127.0.0.1:8080/my";, total_result); where total_result is JSON string: [{"QID":3,"AID":3}, {"SubAID":[4]}, {"MinArea":"10","MaxArea":"90"}] Handler is look l

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

2015-11-28 Thread Suliman via Digitalmars-d-learn
And the second question. Why I am getting next error after attempt to write to console JSON request: Error: cannot resolve type for res.writeJsonBody(T)(T data int status = HTTPStatus.OK, string content_type = "application/json; charset=UF-8", bool allow_chunked = false) void action(HTTPServ

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

2015-11-28 Thread Suliman via Digitalmars-d-learn
On Saturday, 28 November 2015 at 18:46:05 UTC, Suliman wrote: And the second question. Why I am getting next error after attempt to write to console JSON request: Error: cannot resolve type for res.writeJsonBody(T)(T data int status = HTTPStatus.OK, string content_type = "application/json; ch

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

2015-11-28 Thread Suliman via Digitalmars-d-learn
On Saturday, 28 November 2015 at 18:57:53 UTC, anonymous wrote: On 28.11.2015 19:51, Suliman wrote: Eghm, sorry. Not req, but res, but again errr: void action(HTTPServerRequest req, HTTPServerResponse res) { writeln(req.writeJsonBody); } Error: no property 'writeJsonBody' for type 'vibe.h

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

2015-11-28 Thread Suliman via Digitalmars-d-learn
And also I can't understand difference between HTTPClientRequest and HTTPServerRequest For example if I am getting request from web-browser what I should use? And why?

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

2015-11-28 Thread Suliman via Digitalmars-d-learn
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?

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

2015-11-28 Thread Suliman via Digitalmars-d-learn
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 application (vibe.d) makes a request, it is the client. If the req

How to check session before access to static page?

2015-12-03 Thread Suliman via Digitalmars-d-learn
void main() { auto router = new URLRouter; router.get("/", serveStaticFiles("D:\\code\\onlineTest\\index.html")); router.get("/admin", serveStaticFiles("D:\\code\\onlineTest\\admin.html")); router.any("/foo", &foo); auto settings = new HTTPServerSettings; settings.port

How to return user name from vibed session?

2015-12-10 Thread Suliman via Digitalmars-d-learn
Vibed have method get for user session http://vibed.org/api/vibe.http.session/SessionStore I set user name for session like this: req.session.set("username", "admin"); But I can't understand how to get user name from it: abstract std.variant.VariantN!(20) get( string id, string name, laz

Re: How to return user name from vibed session?

2015-12-10 Thread Suliman via Digitalmars-d-learn
On Thursday, 10 December 2015 at 12:21:40 UTC, Adrian Matoga wrote: On Thursday, 10 December 2015 at 11:36:20 UTC, Suliman wrote: Vibed have method get for user session http://vibed.org/api/vibe.http.session/SessionStore I set user name for session like this: req.session.set("username", "admin

Re: How to return user name from vibed session?

2015-12-10 Thread Suliman via Digitalmars-d-learn
On Thursday, 10 December 2015 at 12:30:51 UTC, Suliman wrote: On Thursday, 10 December 2015 at 12:21:40 UTC, Adrian Matoga wrote: On Thursday, 10 December 2015 at 11:36:20 UTC, Suliman wrote: Vibed have method get for user session http://vibed.org/api/vibe.http.session/SessionStore I set user

Re: How to return user name from vibed session?

2015-12-10 Thread Suliman via Digitalmars-d-learn
Oh, my issue. Right variant of setting session is: if(dbuser == "admin") // admin name hardcoded { _auth.isAuthorizated = true; req.session.set("username", "admin"); } else { req.session.set("username", dbuser); //set current username in parameter of ses

Re: How to return user name from vibed session?

2015-12-10 Thread Suliman via Digitalmars-d-learn
On Thursday, 10 December 2015 at 13:34:02 UTC, Mike Parker wrote: On Thursday, 10 December 2015 at 13:23:29 UTC, Suliman wrote: But question about why I need to get session info like: writeln("USER Session: ", req.session.get!string("username")); is still actual. When you have a template t

Re: How to return user name from vibed session?

2015-12-10 Thread Suliman via Digitalmars-d-learn
On Thursday, 10 December 2015 at 13:43:58 UTC, Suliman wrote: On Thursday, 10 December 2015 at 13:34:02 UTC, Mike Parker wrote: On Thursday, 10 December 2015 at 13:23:29 UTC, Suliman wrote: But question about why I need to get session info like: writeln("USER Session: ", req.session.get!stri

How to check if result of request to DB is empty?

2015-12-11 Thread Suliman via Digitalmars-d-learn
I am using https://github.com/buggins/ddbc string query_string = (`SELECT user, password FROM otest.myusers where user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`); auto rs = db.stmt.executeQuery(query_string); string dbpassword; string dbuser; while

Re: check variable for undefinedness

2015-12-11 Thread Suliman via Digitalmars-d-learn
if(a is null) How to check if variable "is not null" ?

Re: How to check if result of request to DB is empty?

2015-12-11 Thread Suliman via Digitalmars-d-learn
string query_string = (`SELECT user, password FROM otest.myusers where user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`); Don't piece queries together without escaping the dynamic parts. Imagine what happens when the user enters an apostrophe in the username field. Do you mean to

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
it's seems that next block is execute even if is rs.next() is false: writeln("rs.next()-->", rs.next()); if(!rs.next()) //if user do not in DB { // is execute even if rs.next() is false writeln("Executed, but rs.nst was set to false"); } The output: rs.next()-->false Executed, but rs.nst was s

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 10:36:12 UTC, drug wrote: 12.12.2015 13:28, Suliman пишет: it's seems that next block is execute even if is rs.next() is false: writeln("rs.next()-->", rs.next()); if(!rs.next()) //if user do not in DB { // is execute even if rs.next() is false writeln("Execute

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
Oh sorry! I used wrong host! All ok!

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 11:31:18 UTC, Suliman wrote: Oh sorry! I used wrong host! All ok! Yes, there was issue with host name, but it's do not solve problem. Second DB have same fields and I still getting false instead moving into while loop

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 11:53:51 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:31:18 UTC, Suliman wrote: Oh sorry! I used wrong host! All ok! Yes, there was issue with host name, but it's do not solve problem. Second DB have same fields and I still getting false instead mo

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:14:30 UTC, Vadim Lopatin wrote: On Saturday, 12 December 2015 at 12:06:21 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:53:51 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:31:18 UTC, Suliman wrote: Oh sorry! I used wrong host! All ok! Y

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:36:10 UTC, Suliman wrote: On Saturday, 12 December 2015 at 12:14:30 UTC, Vadim Lopatin wrote: On Saturday, 12 December 2015 at 12:06:21 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:53:51 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:31:1

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 12:43:36 UTC, Suliman wrote: On Saturday, 12 December 2015 at 12:36:10 UTC, Suliman wrote: On Saturday, 12 December 2015 at 12:14:30 UTC, Vadim Lopatin wrote: On Saturday, 12 December 2015 at 12:06:21 UTC, Suliman wrote: On Saturday, 12 December 2015 at 11:53:5

Re: How to check if result of request to DB is empty?

2015-12-12 Thread Suliman via Digitalmars-d-learn
On Saturday, 12 December 2015 at 13:18:12 UTC, anonymous wrote: On 12.12.2015 08:44, Suliman wrote: string query_string = (`SELECT user, password FROM otest.myusers where user LIKE ` ~ `'%` ~ request["username"].to!string ~ `%';`); Don't piece queries together without escaping the dynamic pa

How to replace inside regex?

2015-12-17 Thread Suliman via Digitalmars-d-learn
I can't understand how to replace in regex. I have got next task: find all commas in strings inside quotes and replace them. foo, bar, "hello, user", baz I wrote next regexp that find part that include commas inside the quotes: auto partWithComma = matchAll(line, r); but I can't understand ho

Why `i` not working on foreach loop if it have byLine option

2015-12-17 Thread Suliman via Digitalmars-d-learn
Next code produce error: foreach(i, line;fileContent.byLine) Error: cannot infer argument types, expected 1 argument, not 2 Why it's do not work?

How to build dfmt?

2016-01-01 Thread Suliman via Digitalmars-d-learn
https://github.com/Hackerpilot/dfmt After run build.bat nothing do not happens. How can I build it?

Error: no property 'select' for type 'ddbc.core.Statement'

2016-01-31 Thread Suliman via Digitalmars-d-learn
I hope that here I will get answer faster then on https://github.com/buggins/ddbc/issues/18 I am using ddbc diver for access to mysql. I need to return result of request to struct. My code is next: import std.stdio; import ddbc.all; import std.stdio; import std.conv; void main() { st

Re: Proper Use of Assert and Enforce

2016-02-05 Thread Suliman via Digitalmars-d-learn
It is purely a way to make throwing an exception use a syntax similar to assert and save a line of code. if(!condition) throw new Exception(msg); becomes enforce(condition, msg); So enforce is just macros on top of: if(!condition) throw new Exception(msg); ?

Re: Proper Use of Assert and Enforce

2016-02-05 Thread Suliman via Digitalmars-d-learn
On Friday, 5 February 2016 at 08:45:00 UTC, Minas Mina wrote: On Wednesday, 14 March 2012 at 05:44:24 UTC, Chris Pons wrote: I'm new, and trying to incorporate assert and enforce into my program properly. My question revolves around, the fact that assert is only evaluated when using the debug

why mkdir can't create tree of dirs?

2016-02-09 Thread Suliman via Digitalmars-d-learn
It's look like that I can only create one nesting level sub folder, for example there is exists dir: D:\foo I can't create dir D:\foo\bar\baz I can only create D:\foo\bar D:\foo\bar Is it's rational limit or it is bug? Here is error when I tried to folder in folder thet do not exists. It's n

Re: why mkdir can't create tree of dirs?

2016-02-10 Thread Suliman via Digitalmars-d-learn
On Tuesday, 9 February 2016 at 23:23:10 UTC, Jonathan M Davis wrote: On Tuesday, February 09, 2016 20:20:59 Suliman via Digitalmars-d-learn wrote: It's look like that I can only create one nesting level sub folder, for example there is exists dir: D:\foo I can't create dir D:\foo\bar

What is the best way to stop App after exception?

2016-02-15 Thread Suliman via Digitalmars-d-learn
I have got class Config with method parseconfig. I need terminate App if parsing of config was failed. The problem that I do not know how to do it better. void parseconfig() { try { //something go wrong } catch(Exception e) { writeln(e.msg); // throw any exception here } } But my

Re: What is the best way to stop App after exception?

2016-02-15 Thread Suliman via Digitalmars-d-learn
On Monday, 15 February 2016 at 15:17:01 UTC, tcak wrote: On Monday, 15 February 2016 at 11:38:05 UTC, Suliman wrote: I have got class Config with method parseconfig. I need terminate App if parsing of config was failed. The problem that I do not know how to do it better. void parseconfig() {

  1   2   3   4   5   >