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 dub.sdl ext string:

"dflags-windows-x86": ["-m32mscoff"]


Sorry, it was my mistake. I complied another project. Nothing do 
not working correct string is:

dflags-windows-x86 "-m32mscoff"

But I got again linking problem.


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

Always compile vibe.d with mscoff


Could you show command to compile with mscoff?


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\Local\dub\packages\vibe-d-0.8.4\vibe-d\tls\.dub\build\openssl-release-windows-x86-dmd_2084-F1EDC8E792A20905C7802AF7FD58830B\vibe-d_tls.lib(openssl)
 Error 42: Symbol Undefined _TLS_server_method
C:\Users\bubnenkov\AppData\Local\dub\packages\vibe-d-0.8.4\vibe-d\tls\.dub\build\openssl-release-windows-x86-dmd_2084-F1EDC8E792A20905C7802AF7FD58830B\vibe-d_tls.lib(openssl)
 Error 42: Symbol Undefined _TLS_client_method
C:\Users\bubnenkov\AppData\Local\dub\packages\vibe-d-0.8.4\vibe-d\tls\.dub\build\openssl-release-windows-x86-dmd_2084-F1EDC8E792A20905C7802AF7FD58830B\vibe-d_tls.lib(openssl)
 Error 42: Symbol Undefined _BN_get_rfc3526_prime_2048
C:\Users\bubnenkov\AppData\Local\dub\packages\vibe-d-0.8.4\vibe-d\tls\.dub\build\openssl-release-windows-x86-dmd_2084-F1EDC8E792A20905C7802AF7FD58830B\vibe-d_tls.lib(openssl)
 Error 42: Symbol Undefined _OPENSSL_init_ssl
Error: linker exited with status 4



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


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?


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 pass copy how I can create array of structures with 
correct response status?


Create new structures?


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) {
// ...
}

// ...

runWorkerTask(, );



void getServiceStatus(MyUrl* url)
{
...
}


 Error: static assert:  "Cannot convert arguments '(MyUrl)' to 
function arguments '(MyUrl*)'."


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, status:
url: http://127.0.0.1:8081/hck3, status:

It's seems that I missed something with refs? Could you help me 
find error?




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 Windows impossible.


Few examples 
https://github.com/huntlabs/hunt-database/issues/24


https://github.com/biozic/d2sqlite3/issues/51


You can look here. It is a on German but Google translator 
does a good job

http://d-land.sepany.de/tutorials/datenbanken/sqlite-erste-schritte/

Kind regards
Andre


Thanks, but also do not working 
https://github.com/adamdruppe/arsd/issues/180


My mistake. Adam's lib works.


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-database/issues/24


https://github.com/biozic/d2sqlite3/issues/51


You can look here. It is a on German but Google translator does 
a good job

http://d-land.sepany.de/tutorials/datenbanken/sqlite-erste-schritte/

Kind regards
Andre


Thanks, but also do not working 
https://github.com/adamdruppe/arsd/issues/180


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




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?


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
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Error 8: Illegal Filename
/NOLOGO /DEBUG /OPT:REF /OPT:ICF /DEFAULTLIB:libcmt 
/DEFAULTLIB:libvcruntime 
"/OUT:.dub\build\application-debug-windows-x86_64-ldc_2081-FC0CCB721F0C7E0D58B93FB1E50E3401\lib.exe" ".dub\obj\lib.obj" "d:\ldc2\lib\ldc_rt.builtins.lib" /LIBPATH:d:/ldc2/bin/../lib phobos2-ldc.lib druntime-ldc.lib kernel32.lib user32.lib gdi32.lib
winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib 
comdlg32.lib advapi32.lib



^
Error: d:\D\dmd2\windows\bin\link.exe failed with status: 1
ldc2 failed with exit code 1.



Could you please try:
dub build --force

And write here if it's help


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)
 Error 42: Symbol Undefined 
__D7lighttp6server10ServerBase6__ctorMFAyaZCQBpQBkQBg

Error: linker exited with status 1
C:\D\dmd2\windows\bin\dmd.exe failed with exit code 1.

VS Build Tools is installed. Whats wrong?


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.
http://www.digitalmars.com/ctg/optlink.html
OPTLINK : Error 8: Illegal Filename
...

Error: C:\D\dmd2\windows\bin\link.exe failed with status: 1
ldc2 failed with exit code 1.

Same with dmd.

How to use LLD linker?


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.


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?


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?


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


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: DLang IDE [RU]

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


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


So if I right understand appender reserve more to prevent 
unneeded allocations.


It's seems that here is calculation new size 
https://github.com/dlang/phobos/blob/master/std/array.d#L3163


So it's allocate more memory that needed, but I can't understand 
it's algorithm. Who could explain how it's work on low level?


How it's make decision how much memory needed to be pre-allocated 
to minimize allocations?


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).


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 am begining to get "502 Bad 
Gateway" error. The service is not down, it's continue to 
working, but on Windows task manager I seen very low memory 
usage (0.4MB) and on Linux I see next: 
https://snag.gy/ban3jX.jpg (i am not familiar with Linux and do 
not sure if process is alive or not because htop do not show it)


The code is *very* simple https://github.com/bubnenkoff/dlang.ru

Is there any ideas how to diagnostic the problem?


I got error https://paste.ofcode.org/exCL5S2vbp6qhYBqj7v6ez

Is it's issue with libevent?

Does even-loop depend on used OS?




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 not down, it's continue to 
working, but on Windows task manager I seen very low memory usage 
(0.4MB) and on Linux I see next: https://snag.gy/ban3jX.jpg (i am 
not familiar with Linux and do not sure if process is alive or 
not because htop do not show it)


The code is *very* simple https://github.com/bubnenkoff/dlang.ru

Is there any ideas how to diagnostic the problem?




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 
to, via the ptr field, is heap allocated.


What is struct? Just name and size?


I'm sorry, I don't understand what you're asking. Can you 
please repeat with more information?


--
  Biotronic


I am trying to understand what structure is. It's name + 
associated with this name data? I can't understand for my self 
what mean no put structure to stack. Just put it's name to it or 
something another?


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 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
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 placing data _only_ on 
stack? But the stack size is very limited (on Widnows it's 
just 1MB).


So how it's work?


Struct's by themselves go on the stack.
If they are allocated via new/malloc its on the heap (and hence 
are pointers).

Same situation with arrays or inside a class.


But for example if I am getting array of structs and getting data 
to it, where it's locating?


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: 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 block.


The only one modification that I did I changes pages names:
extends home

because my main page is home.dt


You have it backwards. You don't render the layout template, 
but the template that extends the layout.


-Steve


Big thanks! Now I understand. Now i redone dlang.ru in diet 
templates.


Am I right understand that include is needed only for small 
includes without any nesting levels?


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

because my main page is home.dt




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
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 of it like an interface, where the "blocks" are function 
prototypes, and your specific view file is a class that 
implements the interface, where you implement the functions by 
defining the blocks.


-Steve


Could you show how to improve my code above? I can't get it 
work...


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, but it have wrong indent. Original 
page (that I am trying to split) have next indents:


doctype html
html
  head
title DLANG.ru
  body
#app
  .MainContainer
.Header
  .HeaderMenu
.HeaderBlock
  router-link(to='/') General
.HeaderBlock
  router-link(to='/FAQ') FAQ
.HeaderBlock
  router-link(to='/book') Book
  .HeaderLoginBlock Sign in
.Middle
  f
.footer (c) DLANG 2017

But I can't get right indents when I am splition it.



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

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 and 
than simpy import in every page. Is it's possible to do with 
vibed?


Oh, I founded answer in docs.


I can't fund way to `include` header and footer in the same docs. 
I cam getting error: "Includes cannot have children"


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 with vibed?


Oh, I founded answer in docs.


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?


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?





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 expect that it will select:

#Header
my header text

##SubHeader
my sub header text

Because: ^#{3}


Have you tried https://regex101.com/

It gives you results and explanations about your regex in 
realtime.


A. Corbi


I tried. But I am getting different behavior in online editor and 
in the code.


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

There reason of issue above is spaces before "#".


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

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 l1 = regex(`(^|\n)#([^#]*)\n([\^]*)(?=\n#[^#]|$)`, ['g', 
'm']);


foreach(t; text.matchAll(l1))
{
writeln(t.hit);
}
}


This code is print to console:

#Header
my header text

How can I modify regex to get it print:

#Header
my header text

##SubHeader
my sub header text

?

I tried different combination, some of them are working in online 
regexp editors, but do not working in D.


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(bigCodeBlock))
{
string t1 = t.hit.replaceFirst(regex("`"),``);
string t2 = t1.replaceFirst(regex("`"),``);
}

}

Here I am replacing `foo` to foo. But got replaced 
data as copy, not in original document. But I need to get 
replacing in original document.


replaceAll is not suitable for it because it's not clear how to 
get open and close tags ( and ).


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 understand which libs 
I should use to get OpenSSL 64 bit work with dlang-request.


32-bit version compile and works fine, but it's fail during 
downloading 300MB file with next error:
core.exception.OutOfMemoryError@src\core\exception.d(696): 
Memory allocation failed


You might wanna read the file in chunks and write in chunks.


It's helped, but it's obviously that D on Windows should have 
64-bit linker out of the box. Because GC on 32-bit machine show a 
lot of bugs.


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 fine, but it's fail during 
downloading 300MB file with next error:
core.exception.OutOfMemoryError@src\core\exception.d(696): Memory 
allocation failed


code:

import std.stdio;
import std.conv;
import std.file;
import std.path;
import std.string;
import std.algorithm;
import std.regex;

import requests;
pragma(lib, "ssl");
pragma(lib, "eay");


void main()
{
string login = "Suliman1";
string pass = "Infinity8"; //*
string url = 
"https://n5eil01u.ecs.nsidc.org/SMAP/SPL3SMP_E.001/2017.07.11/;;


Request request;
	request.addHeaders(["User-Agent": "Mozilla/5.0 (Windows NT 6.1; 
Win64; x64; rv:54.0) Gecko/20100101 Firefox/54.0"]);

request.authenticator = new BasicAuthentication(login, pass);
auto rs = request.get(url);
string content = to!string(rs.responseBody);

string fname = content.matchFirst(`(SMAP_[^"]+)`).hit;

string h5_file = url ~ fname;
string isoXML_file = url ~ fname ~ `.iso.xml`;
string qa_file = url ~ fname.replace(`h5`, `qa`);

string [] arrayFullURLs;
arrayFullURLs ~= h5_file;
arrayFullURLs ~= isoXML_file;
arrayFullURLs ~= qa_file;

foreach(f; arrayFullURLs)
{
writeln("Loading file: ", f);
auto rs1 = request.get(f);
File file = File(baseName(f), "w");
file.write(rs1.responseBody);
}

}

dub.sdl:
name "parser"
dependency "requests" version="~>0.4.2"
dependency "progress" version="~>4.0.3"


--
* please do now hack account because I publish this pass to get 
it's reproduce error easier.


So could anybody explain step-by-step how to get OpenSSL 64 work 
on 64-bit Windows.


On my PC this app eat 500MB of RAM and then failure with error 
above.




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


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("https://scihub.copernicus.eu/dhus/login;, form);

writeln("Output:");
writeln(content);

Return error about login pass. So it's seems that I need to add 
BasicAuthentication method type. But how to add it?



Browser console show next: https://snag.gy/VXaq2R.jpg


Re: Diet template is crush

2017-06-28 Thread Suliman via Digitalmars-d-learn

It's look like issue in another part of code...


Diet template is crush

2017-06-28 Thread Suliman via Digitalmars-d-learn

I can't understand why follow code is crushing:

string error = "503 Server error!";
int error_code = 503;
res.render!("error.dt", error, error_code);

on res string (last in code above) I am getting error:
CoreTaskFiber was terminated unexpectedly: Access Violation

error.dt http://paste.code123.org/91ea2dc1-7396

If delete part:
div.errorPageText #{error}
div.errorPageImg
- if (error_code == 404)
img(src='img/error_404.png')
- else
img(src='img/error_503.png')

All work fine. It's seems that something wrong with args `error, 
error_code`.







How to add class in DIET template

2017-06-23 Thread Suliman via Digitalmars-d-learn

I need to get external variable and make class by it's value

- string mystr = "lng-" ~ language;
- foreach(i, line; arrayOfLines )
li
code.mystr #{line}

I need to get HTML code like this:


some D code


But class name become "mystr" and I am getting:


some D code


How to fix it?


Re: How to cleanup array of structs?

2017-06-04 Thread Suliman via Digitalmars-d-learn

// Will reuse the array, overwriting existing data.
// If other parts of the program are using existing data
// in the array, this will lead to hard-to-track-down bugs.
mytracks.length = 0;
mytracks.assumeSafeAppend();


Could you give an example where it can lead bugs? Do you mean 
multi-thread apps?


How to cleanup array of structs?

2017-06-02 Thread Suliman via Digitalmars-d-learn
I remember that there was topic about remobing data from 
struct/arrays of structs. But I do not remember what is idiomatic 
way to do it, and can't google it.


something like:
struct MyTrack
{
ulong id;
string recordDate;
int velocity;
int maxAllowedSpeedForRoad;
}

MyTrack mytrack;
MyTrack [] mytracks;

// filling

mytracks.clean() or what?


Re: Best way for handle missing args in REST interface in vibed

2017-05-30 Thread Suliman via Digitalmars-d-learn
I had post question here 
http://forum.rejectedsoftware.com/groups/rejectedsoftware.vibed/thread/43511/


Re: Best way for handle missing args in REST interface in vibed

2017-05-29 Thread Suliman via Digitalmars-d-learn

@rootPathFromName
interface API
{
@path("mytrack")   @method(HTTPMethod.GET)Json 
doTrackSpeedAnalyze(int trackid, string startDateTime, string 
endDateTime);

}

class MyRouter : API
{
   Config config;
   Database database;
   this(Config config, Database database)
   {
this.config = config;
this.database = database;
   }

@path("/")
void foo(string _error = null) // I expect that this will 
be called if exception happen in doTrackSpeedAnalyze

{
writeln("Error in console"); // does not writing on 
console

}
 override:
@errorDisplay!foo
Json doTrackSpeedAnalyze(int trackid, string 
startDateTime, string endDateTime) // 
/api/mytrack?trackid=123=2000=2010

{
if(endDateTime == "0")
{
throw new Exception("Some fields are empty");
}
return Json.emptyObject;
}

}


What I am doing wrong? Should I do  override for foo? Should foo 
present in `interface`?


Re: Best way for handle missing args in REST interface in vibed

2017-05-29 Thread Suliman via Digitalmars-d-learn

I wrote next code:

void foo(string _error = null)
{
writeln("Error");
}
override:
@errorDisplay!foo
Json doTrackSpeedAnalyze(int trackid, string 
startDateTime, string endDateTime) // 
/api/mytrack?trackid=123=2000=2010

{
if(endDateTime.length == 0)
{
throw new Exception("End Date must not be empty");
}
return Json.emptyObject;
}

If I access to url:  /api/mytrack?trackid=123=2000 
(witout endDateTime) I am expecting execution foo() block, but it 
does not happens. Why?


And what do Exception here? Why should handle it?


Re: Best way for handle missing args in REST interface in vibed

2017-05-29 Thread Suliman via Digitalmars-d-learn

On Monday, 29 May 2017 at 12:23:59 UTC, Suliman wrote:
I am doing REST interface with vibed. And thinking about 
handling errors, if users forgot to pass all expected args in 
function.


For example:
foo(int x, int y) // get request
{

}

/api/foo?x=111

And if user is forgot to pass `y` we will get error in the 
browser. What is the right way to handle curch cases?


Wrap is with try-catch looks wrong.


It's seems I found how to do it 
http://vibed.org/api/vibe.web.web/errorDisplay


Best way for handle missing args in REST interface in vibed

2017-05-29 Thread Suliman via Digitalmars-d-learn
I am doing REST interface with vibed. And thinking about handling 
errors, if users forgot to pass all expected args in function.


For example:
foo(int x, int y) // get request
{

}

/api/foo?x=111

And if user is forgot to pass `y` we will get error in the 
browser. What is the right way to handle curch cases?


Wrap is with try-catch looks wrong.


Getopt default int init and zero

2017-05-19 Thread Suliman via Digitalmars-d-learn
I would like to check if user specified `0` as getopt parameter. 
But the problem that `int`'s are default in `0`. So if user did 
not specified nothing `int x` will be zero, and all other code 
will work as if it's zero.


In std.typecons I found Nullable that allow init int to zero. I 
tried to do:


Nullable!int dateInterval;

try
{
auto helpInformation = getopt(args,
"interval|i",  "Interval of selection in dayes", 
);
}

But I am getting error:

conv.d(194,24): Error: template std.conv.toImpl cannot deduce 
function from argument types !(Nullable!int)(string), candidates 
are:
conv.d(435,11):std.conv.toImpl(T, S)(S value) if 
(isImplicitlyConvertible!(S, T) && !isEnumStrToStr!(S, T) && 
!isNullToStr!(S, T))
conv.d(549,11):std.conv.toImpl(T, S)(ref S s) if 
(isStaticArray!S)
conv.d(565,11):std.conv.toImpl(T, S)(S value) if 
(!isImplicitlyConvertible!(S, T) && is(typeof(S.init.opCast!T()) 
: T) && !isExactSomeString!T && !is(typeof(T(value
conv.d(616,11):std.conv.toImpl(T, S)(S value) if 
(!isImplicitlyConvertible!(S, T) && is(T == struct) && 
is(typeof(T(value
conv.d(665,11):std.conv.toImpl(T, S)(S value) if 
(!isImplicitlyConvertible!(S, T) && is(T == class) && 
is(typeof(new T(value

conv.d(194,24):... (9 more, -v to show) ...
getopt.d(894,56): Error: template instance 
std.conv.to!(Nullable!int).to!string error instantiating
getopt.d(749,46):instantiated from here: 
handleOption!(Nullable!int*)
getopt.d(758,23):instantiated from here: 
getoptImpl!(string, string, Nullable!int*, string, string, bool*)
getopt.d(436,15):instantiated from here: 
getoptImpl!(string, string, int[]*, string, string, 
Nullable!int*, string, string, bool*)
source\app.d(41,32):instantiated from here: 
getopt!(string, string, int[]*, string, string, Nullable!int*, 
string, string, bool*)


How to write parser?

2017-05-14 Thread Suliman via Digitalmars-d-learn
I am trying to learn how to write text parser. I have example doc 
with follow format:


#Header
my header text

##SubHeader
my sub header text

###Sub3Header
my sub 3 text

#Header21
my header2 text

##SubHeader21
my header2 text

###SubHeader22
my header3 text


I would like to wrap all level(#) tags to HTML div's, to get it's 
look like:



#Header
my header text

##SubHeader
my sub header text

###Sub3Header
my sub 3 text




#Header21
my header2 text

##SubHeader21
my header2 text

###SubHeader22
my header3 text




It's seems that I wrong understand parser logic. I am trying to 
do it's in next way:


bool isH1Open;
bool isH2Open;
bool isH3Open;

string newcontent;

foreach(line; content.lineSplitter)
{
if(line.length > 3) // to prevent access to line < 3 symblos
{
if(!isH1Open && line[0] == '#' && line[1] != '#')
{
isH1Open = true;
line = `` ~ "\n" ~ line ;
newcontent ~= line;
continue;
}


if(isH2Open && line[1] == '#' && line[2] != '#')
{
isH2Open = false;
line = "\n" ~ `` ~ "\n";
newcontent ~= line;
continue;
}

if(isH1Open && line[0] == '#' && line[1] != '#')
{
isH1Open = false;
line = "\n" ~ `` ~ "\n";
newcontent ~= line;
continue;
}


if(!isH2Open && line[1] == '#' && line[2] != '#')
{
isH2Open = true;
line = "\n" ~ `` ~ "\n" ~ line ;
newcontent ~= line;
continue;
}


}

But I am getting wrong output:


#Header

##SubHeader




#Header31

##SubHeader31

it's there any better way to parse such format?



Re: File Input

2017-05-07 Thread Suliman via Digitalmars-d-learn

On Sunday, 7 May 2017 at 13:57:47 UTC, JV wrote:

Hi guys

I'd like to know how to get an input from the user to be stored 
in a .txt file using import std.file and is it possible to 
directly write in a .txt file without using a variable to store 
the user input?


Thanks for the answer in advance my mind is kinda jumbled about 
this since im new to this language.


http://nomad.so/2015/09/working-with-files-in-the-d-programming-language/


Re: problem with std.variant rounding

2017-05-02 Thread Suliman via Digitalmars-d-learn

On Tuesday, 2 May 2017 at 08:02:23 UTC, Suliman wrote:
On Saturday, 29 April 2017 at 08:57:09 UTC, Petar Kirov 
[ZombineDev] wrote:

On Friday, 28 April 2017 at 18:08:38 UTC, H. S. Teoh wrote:
On Fri, Apr 28, 2017 at 04:42:28PM +, via 
Digitalmars-d-learn wrote: [...]

writefln(text("%.", i, "f"), x);

[...]

There's no need to use text() here:

writefln("%.*f", i, x);

does what you want.


T


Thanks, I missed the fact that * could be used for specifying 
the precision, in addition to the width.


I need co concatenate string with variant type (I am doing SQL 
query).


What is the best way to put it? It's seems that if I am doing 
simple `replace`


string sql = "..."
sql.replace(`37.72308`, 
to!string(cargpspoint.lon)).replace(`55.47957`, 
to!string(cargpspoint.lat))


I am loosing accuracy. Is there any better way?


I did:
sql_distance.replace(`37.72308`, format("%f",cargpspoint.lon))

It's seems that it's work ok. But is there any better way, or 
it's ok?


Re: problem with std.variant rounding

2017-05-02 Thread Suliman via Digitalmars-d-learn
On Saturday, 29 April 2017 at 08:57:09 UTC, Petar Kirov 
[ZombineDev] wrote:

On Friday, 28 April 2017 at 18:08:38 UTC, H. S. Teoh wrote:
On Fri, Apr 28, 2017 at 04:42:28PM +, via 
Digitalmars-d-learn wrote: [...]

writefln(text("%.", i, "f"), x);

[...]

There's no need to use text() here:

writefln("%.*f", i, x);

does what you want.


T


Thanks, I missed the fact that * could be used for specifying 
the precision, in addition to the width.


I need co concatenate string with variant type (I am doing SQL 
query).


What is the best way to put it? It's seems that if I am doing 
simple `replace`


string sql = "..."
sql.replace(`37.72308`, 
to!string(cargpspoint.lon)).replace(`55.47957`, 
to!string(cargpspoint.lat))


I am loosing accuracy. Is there any better way?


Re: problem with std.variant rounding

2017-04-28 Thread Suliman via Digitalmars-d-learn

On Friday, 28 April 2017 at 16:49:18 UTC, kinke wrote:

On Friday, 28 April 2017 at 16:24:55 UTC, Suliman wrote:

import std.stdio;
import std.variant;

void main()
{
Variant b = 56.051151;
float x = b.coerce!float;
writeln(x);
}


56.0512


void main()
{
import core.stdc.stdio;
import std.stdio;

double d = 56.051151;
writeln(d);
printf("%g %f %a\n\n", d, d, d);

real r = 56.051151L;
writeln(r);
printf("%Lg %Lf %La\n", r, r, r);
}

=>

56.0512
56.0512 56.051151 0x1.c068c1db0142fp+5

56.0512
56.0512 56.051151 0x1.c068c1db0142f61ep+5

So using write[ln]() to check floating-point values isn't a 
good idea as you may lose precision; hex formatting (or a 
proper debugger) is a much better choice. Additionally, your 
value isn't *exactly* representable; you may want to read up on 
floating-point representations if that's unclear.


Yeah! It was issue with rounding during writeln


Re: problem with std.variant rounding

2017-04-28 Thread Suliman via Digitalmars-d-learn

On Friday, 28 April 2017 at 15:45:25 UTC, Suliman wrote:

I am using https://github.com/mysql-d/mysql-native
It's return from DB variant data-type.

My DB include value: 56.051151 (double type in DB)

I need to extract it. I tried several variants:

writeln(point[3].coerce!float);
writeln(point[3].coerce!string);
writeln(point[3].coerce!double);

but all of them return me it as: 56.0512

How to return exactly 56.051151 ?


import std.stdio;
import std.variant;

void main()
{
Variant b = 56.051151;
float x = b.coerce!float;
writeln(x);
}


56.0512


problem with std.variant rounding

2017-04-28 Thread Suliman via Digitalmars-d-learn

I am using https://github.com/mysql-d/mysql-native
It's return from DB variant data-type.

My DB include value: 56.051151 (double type in DB)

I need to extract it. I tried several variants:

writeln(point[3].coerce!float);
writeln(point[3].coerce!string);
writeln(point[3].coerce!double);

but all of them return me it as: 56.0512

How to return exactly 56.051151 ?


Re: Can't break App execution by ctrl+c

2017-04-27 Thread Suliman via Digitalmars-d-learn

Just catch the empty result exception.
I do not want to go to catch block if I have empty result. I just 
want to get there if any other error type occur. If result is 
empty that simply skip this step.


Re: Can't break App execution by ctrl+c

2017-04-27 Thread Suliman via Digitalmars-d-learn

On Thursday, 27 April 2017 at 12:25:11 UTC, Adam D. Ruppe wrote:

On Thursday, 27 April 2017 at 12:17:12 UTC, Suliman wrote:

Before my code handle empty result in `catch` block.


You must be catching the ctrl+c exception... don't do that. 
Just catch the empty result exception.


The issue is gone after removing 
http://code.dlang.org/packages/consoled
it's look like that it's produced error. Now ctrl+c is woking 
fine...


Can't break App execution by ctrl+c

2017-04-27 Thread Suliman via Digitalmars-d-learn
Before my code handle empty result in `catch` block. Then I moved 
it's checking to main loop, and now I can't abort App execution 
by ctrl+c. It's simply continue working.


Here is my code:

foreach(cargpspoint; cargpspoints)
{
auto cmd_dist = new PGCommand(pgconnection, sql_query));
try
{
 auto nresult = cmd_dist.executeQuery();
 auto nanswer = nresult.array;
 nresult.close();
if(nanswer.empty)
{
 continue;
}

}

OS: Windows.




Re: How to fix date format?

2017-04-26 Thread Suliman via Digitalmars-d-learn
On Wednesday, 26 April 2017 at 05:21:32 UTC, Jonathan M Davis 
wrote:
On Wednesday, April 26, 2017 04:02:12 Suliman via 
Digitalmars-d-learn wrote:

I tried to do:

writeln(DateTime.toISOExtString(DateTime.fromSimpleString(point[1].coerce!
string)));

But got error:

Error: function std.datetime.DateTime.toISOExtString () const 
is

not callable using argument types (DateTime)
Error: function database.Database.getSingleTrackInfo no return
exp; or assert(0); at end of function


toISOExtString is a normal member function on DateTime, not a 
static member function. If point[1].coerce!string is giving you 
a string in Boost's "simple time" format (e.g. "2016-Jan-04 
12:19:17"), then 
DateTime.fromSimpleString(point[1].coerce!string) will give you 
a DateTime. Then if you called toISOExtString() on that, e.g.


DateTime dt = DateTime.fromSimpleString(point[1].coerce!string);
string str = dt.toISOExtString();

then the string would be in the ISO extended format (e.g. 
"2016-01-04T12:19:17"). If you then wanted that in the format 
"2016-01-04 12:19:17", then you could just replace the 'T' with 
' ', e.g.


DateTime dt = DateTime.fromSimpleString(point[1].coerce!string);
string str = dt.toISOExtString().replace("T", " ");

And if you have "2016-01-04 12:19:17", and you want to convert 
that to the Boost simple time format, you could do


DateTime dt = DateTime.fromISOExtString(str.replace(" ", "T"))
auto simpleStr = dt.toSimpleString();

Hopefully, that helps.

- Jonathan M Davis


Thanks! That's work!

But why I can't do it in single line like:
string dt = 
DateTime.toISOExtString(DateTime.fromSimpleString(point[1].coerce!string));
"Error: function std.datetime.DateTime.toISOExtString () const is 
not callable using argument types (DateTime)"


And should do:

DateTime dt = DateTime.fromSimpleString(point[1].coerce!string);
string str = dt.toISOExtString();


Re: How to fix date format?

2017-04-25 Thread Suliman via Digitalmars-d-learn

I tried to do:

writeln(DateTime.toISOExtString(DateTime.fromSimpleString(point[1].coerce!string)));

But got error:

Error: function std.datetime.DateTime.toISOExtString () const is 
not callable using argument types (DateTime)
Error: function database.Database.getSingleTrackInfo no return 
exp; or assert(0); at end of function


Re: How to fix date format?

2017-04-25 Thread Suliman via Digitalmars-d-learn

On Tuesday, 25 April 2017 at 20:10:02 UTC, Jonathan M Davis wrote:
On Tuesday, April 25, 2017 17:41:25 Suliman via 
Digitalmars-d-learn wrote:
I am using mysql native. Date in DB have next format: 
2016-11-01 06:19:37


But every tile when I am trying to get it I am getting such
format:
2016-Oct-31 15:37:24

I use next code:
writeln(point[1].coerce!string);

Why coerce is forcing format changing? How I can extract 
result as without month name between digits or easily convert 
it in proper data format?


What types are dealing with here? What is point[1]?

- Jonathan M Davis


writeln(point[1].coerce!string);
writeln(point[1].type);


std.datetime.DateTime
std.variant.VariantN!20LU.VariantN


How to fix date format?

2017-04-25 Thread Suliman via Digitalmars-d-learn
I am using mysql native. Date in DB have next format: 2016-11-01 
06:19:37


But every tile when I am trying to get it I am getting such 
format:

2016-Oct-31 15:37:24

I use next code:
writeln(point[1].coerce!string);

Why coerce is forcing format changing? How I can extract result 
as without month name between digits or easily convert it in 
proper data format?


Why File is exists in std.stdio and in std.file?

2017-04-25 Thread Suliman via Digitalmars-d-learn

Just interesting. Is there any rational reasons for this decision?


Re: The app hanging after reach 1750MB of RAM

2017-04-24 Thread Suliman via Digitalmars-d-learn
The problem is solved. See for more detail 
https://github.com/mysql-d/mysql-native/issues/104


Re: The app hanging after reach 1750MB of RAM

2017-04-19 Thread Suliman via Digitalmars-d-learn

On Wednesday, 19 April 2017 at 15:18:32 UTC, crimaniak wrote:

On Tuesday, 18 April 2017 at 11:43:24 UTC, Suliman wrote:
I am writing app that extract data from DB to array of 
structures.


void getSingleTrackInfo()
{

foreach(item; getTablesGPSSensorList)
{
ResultRange result = mysqlconnection.query(sqlquery);
auto MySQLPointsLonLat = result.array;
Is ResultRange closing query when exhausted? Did you try to 
call .close() on it after work?


Yes I tried:

ResultRange result = mysqlconnection.query(sqlquery);
auto MySQLPointsLonLat = result.array;
result.close();

Did not help :(


Re: The app hanging after reach 1750MB of RAM

2017-04-19 Thread Suliman via Digitalmars-d-learn
I have added GC.stat 
https://dlang.org/library/core/memory/gc.stats.html here the 
result:


freeSize: 49698640  | usedSize: 170502320
freeSize: 41174592  | usedSize: 217823680
freeSize: 53868576  | usedSize: 247072736
freeSize: 86494800  | usedSize: 307769776
freeSize: 58176640  | usedSize: 499665792
freeSize: 148233232 | usedSize: 534389744
freeSize: 148141376 | usedSize: 534481600
freeSize: 108467312 | usedSize: 641264528
freeSize: 55118432  | usedSize: 694613408
freeSize: 80579472  | usedSize: 803370096
freeSize: 7880  | usedSize: 1006831680
freeSize: 291629360 | usedSize: 860755664
freeSize: 242912736 | usedSize: 976581152
freeSize: 241673232 | usedSize: 977820656
freeSize: 168092160 | usedSize: 1118510592
freeSize: 128405616 | usedSize: 1426632592
freeSize: 73146272  | usedSize: 1616109664
freeSize: 17962320  | usedSize: 1671293616
freeSize: 20342912  | usedSize: 1736021888

on the last value app is hanging.




Re: The app hanging after reach 1750MB of RAM

2017-04-19 Thread Suliman via Digitalmars-d-learn
auto mymem = cargpspoints.length * 
typeof(cargpspoints[0]).sizeof;			

writeln(mymem);

And it's print: 16963440
it's about 16MB...

What is takes all other memory?


1. You're measuring it wrong. Array length is already measured 
in terms of type size.


So should I do:
cargpspoints.length * cargpspoints[0].sizeof ?

Btw, `cargpspoints.length * typeof(cargpspoints[0]).sizeof` and 
`cargpspoints.length * cargpspoints[0].sizeof` show same result.


Re: The app hanging after reach 1750MB of RAM

2017-04-18 Thread Suliman via Digitalmars-d-learn

On Tuesday, 18 April 2017 at 14:15:59 UTC, Stanislav Blinov wrote:
On Tuesday, 18 April 2017 at 14:09:28 UTC, Stanislav Blinov 
wrote:



foreach(row; result)
{
arr ~= row.toStruct(cargpspoint);
}


Sorry, this should be

foreach(row; result)
{
row.toStruct(cargpspoint);
arr ~= cargpspoint;
}


Thanks I will try! But why in my code memory do not released? Do 
you have any idea?


Re: The app hanging after reach 1750MB of RAM

2017-04-18 Thread Suliman via Digitalmars-d-learn
Also I can't understand why app take so much memory? I checked 
array of structures size with this code:


auto mymem = cargpspoints.length * 
typeof(cargpspoints[0]).sizeof;			

writeln(mymem);

And it's print: 16963440
it's about 16MB...

What is takes all other memory?


The app hanging after reach 1750MB of RAM

2017-04-18 Thread Suliman via Digitalmars-d-learn

I am writing app that extract data from DB to array of structures.

void getSingleTrackInfo()
{

foreach(item; getTablesGPSSensorList)
{
ResultRange result = mysqlconnection.query(sqlquery);
auto MySQLPointsLonLat = result.array;

carGPSPoint cargpspoint; // create struct
carGPSPoint [] cargpspoints; // create array of 
structures

foreach(i, point;MySQLPointsLonLat)
{
cargpspoint.id = point[0].coerce!ulong;
cargpspoint.recordDate = point[1].coerce!string;
cargpspoint.velocity = point[2].coerce!double;
cargpspoint.lat = point[3].coerce!string;
cargpspoint.lon = point[4].coerce!string;
cargpspoints ~=cargpspoint;

}

}
}


I expected that on every step:
`foreach(item; getTablesGPSSensorList)` structures `carGPSPoint` 
will be recreated and memory will be free. But App after starting 
begin eat memory, and do it till reach 1750 of RAM. After it it's 
not crush, but simply stop other processing.


1. By the code on every iterate `carGPSPoint` should be recreated 
and memory should be free, why this does not happen?

2. How to free my memory?



Re: Can't build simple project. Very strange errors

2017-04-17 Thread Suliman via Digitalmars-d-learn

On Friday, 14 April 2017 at 15:53:18 UTC, Rene Zwanenburg wrote:

On Friday, 14 April 2017 at 15:42:33 UTC, Suliman wrote:
On Friday, 14 April 2017 at 15:40:18 UTC, Rene Zwanenburg 
wrote:

On Friday, 14 April 2017 at 15:31:21 UTC, Suliman wrote:
On Friday, 14 April 2017 at 15:22:49 UTC, Rene Zwanenburg 
wrote:

On Friday, 14 April 2017 at 09:49:09 UTC, Suliman wrote:

on: dub build --compiler=ldc2


link

OPTLINK (R) for Win32  Release 8.00.17


Optlink isn't able to link object files produced by ldc. 
Could you try an x64_86 build? You'll need the Microsoft 
linker.


I do not have VS on my PC :(


You don't need VS, the Windows SDK should be fine too. It's a 
free download :)


How to check if it's installed and how to use linker from it?


If it's installed you can find it in the programs and features 
list as 'Windows Software Development Kit for Windows X'. The 
DMD installer will look for it during installation, so 
reinstalling DMD after installing the SDK should work. I'm not 
sure how LDC does it, but last time I installed LDC it also 
just worked.


I checked, it's installed. I reinstall dmd, but got same error 
with linker.


Re: Can't pass data from filter to each

2017-04-17 Thread Suliman via Digitalmars-d-learn
New question. Can I put result of filtering in itself without 
creation of new variables like x:


auto x = 
MySQLTablesRange.array.filter!(a=>a[0].coerce!string.canFind("_"));


Can't pass data from filter to each

2017-04-17 Thread Suliman via Digitalmars-d-learn
I am writing lambda function. I need filter data at first step 
and than do dome operation on them (for start simply print on the 
screen. I wrote next code:


MySQLTablesRange.filter!(a=>a[0].coerce!string.canFind("_")).each!(a => 
to!int(a[0].coerce!string.split("_")[1]).writeln);


But it's seem that each do not handle any data. I tested if data 
is corectly filtered and next code successfully print it's output.


auto t = 
MySQLTablesRange.array.filter!(a=>a[0].coerce!string.canFind("_"));

t.each!(a=>a[0].coerce!string.writeln);

But what is wrong with first code?


Re: Why map return [] ?

2017-04-14 Thread Suliman via Digitalmars-d-learn

On Friday, 14 April 2017 at 15:55:13 UTC, Rene Zwanenburg wrote:

On Friday, 14 April 2017 at 15:49:00 UTC, Suliman wrote:
I found problem! ResultRange should be converted to array 
before it can be `map`ed


That shouldn't be necessary. Can you post your complete code?


ResultRange MySQLTablesRange = mysqlconnection.query(`SELECT 
table_name FROM information_schema.tables;`);
auto x = 
MySQLTablesRange.map!(a=>a[0].coerce!string.split("_")[1]);

writeln(x);

output: []
while: MySQLTablesRange.array.map!...

output result



Re: Why map return [] ?

2017-04-14 Thread Suliman via Digitalmars-d-learn

On Friday, 14 April 2017 at 15:38:19 UTC, Suliman wrote:

On Friday, 14 April 2017 at 15:35:15 UTC, cym13 wrote:

On Friday, 14 April 2017 at 15:29:33 UTC, Suliman wrote:

auto x = MySQLTablesRange.map!(a=>a);
writeln(x);

return: []

while next code:
MySQLTablesRange.each!(a=>a.writeln);

return data line by line.

Why?


What library is that supposed to be?


http://code.dlang.org/packages/mysql-native


I found problem! ResultRange should be converted to array before 
it can be `map`ed


Re: Can't build simple project. Very strange errors

2017-04-14 Thread Suliman via Digitalmars-d-learn

On Friday, 14 April 2017 at 15:40:18 UTC, Rene Zwanenburg wrote:

On Friday, 14 April 2017 at 15:31:21 UTC, Suliman wrote:
On Friday, 14 April 2017 at 15:22:49 UTC, Rene Zwanenburg 
wrote:

On Friday, 14 April 2017 at 09:49:09 UTC, Suliman wrote:

on: dub build --compiler=ldc2


link

OPTLINK (R) for Win32  Release 8.00.17


Optlink isn't able to link object files produced by ldc. 
Could you try an x64_86 build? You'll need the Microsoft 
linker.


I do not have VS on my PC :(


You don't need VS, the Windows SDK should be fine too. It's a 
free download :)


How to check if it's installed and how to use linker from it?


Re: Why map return [] ?

2017-04-14 Thread Suliman via Digitalmars-d-learn

On Friday, 14 April 2017 at 15:35:15 UTC, cym13 wrote:

On Friday, 14 April 2017 at 15:29:33 UTC, Suliman wrote:

auto x = MySQLTablesRange.map!(a=>a);
writeln(x);

return: []

while next code:
MySQLTablesRange.each!(a=>a.writeln);

return data line by line.

Why?


What library is that supposed to be?


http://code.dlang.org/packages/mysql-native


Re: Can't build simple project. Very strange errors

2017-04-14 Thread Suliman via Digitalmars-d-learn

On Friday, 14 April 2017 at 15:22:49 UTC, Rene Zwanenburg wrote:

On Friday, 14 April 2017 at 09:49:09 UTC, Suliman wrote:

on: dub build --compiler=ldc2


link

OPTLINK (R) for Win32  Release 8.00.17


Optlink isn't able to link object files produced by ldc. Could 
you try an x64_86 build? You'll need the Microsoft linker.


I do not have VS on my PC :(


Why map return [] ?

2017-04-14 Thread Suliman via Digitalmars-d-learn

auto x = MySQLTablesRange.map!(a=>a);
writeln(x);

return: []

while next code:
MySQLTablesRange.each!(a=>a.writeln);

return data line by line.

Why?


Re: Can't build simple project. Very strange errors

2017-04-14 Thread Suliman via Digitalmars-d-learn

On Friday, 14 April 2017 at 10:40:00 UTC, Suliman wrote:
I checked all possible combination of dmd and vibed (0.7.30 
brunch). No result. Only a little bit another error:


Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6serv╤10listenHTTPFCАТЯ8АДЩSАЕМщttingsАТж24АКжRequestHandlerZSАТ╙2АДнLАЕЎer

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6router9URLRouter7__ClassZ

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6router9URLRouter6__ctorMFAyaZC4vibe4http6router9URLRouter

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6server18HTTPServerSettings7__ClassZ

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6server18HTTPServerSettings6__ctorMFZC4vibe4http6server18HTTPServerSettings

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe3web10validation10ValidEmail11__xopEqualsFKxS4vibe3web10validation10ValidEmailKxS4vibe3web10validation10ValidEmailZb


I can build project only in release mode with:
`dub --build=release`

Otherwise I am getting errors descripted above


Re: Can't build simple project. Very strange errors

2017-04-14 Thread Suliman via Digitalmars-d-learn
I checked all possible combination of dmd and vibed (0.7.30 
brunch). No result. Only a little bit another error:


Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6serv╤10listenHTTPFCАТЯ8АДЩSАЕМщttingsАТж24АКжRequestHandlerZSАТ╙2АДнLАЕЎer

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined _D4vibe4http6router9URLRouter7__ClassZ
.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6router9URLRouter6__ctorMFAyaZC4vibe4http6router9URLRouter

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6server18HTTPServerSettings7__ClassZ

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe4http6server18HTTPServerSettings6__ctorMFZC4vibe4http6server18HTTPServerSettings

.dub\build\application-debug-windows-x86-dmd_2073-5BBFAE5ECCC36FEC42565956CE2F0D0A\roadpoint.obj(roadpoint)
 Error 42: Symbol Undefined 
_D4vibe3web10validation10ValidEmail11__xopEqualsFKxS4vibe3web10validation10ValidEmailKxS4vibe3web10validation10ValidEmailZb


Re: Can't build simple project. Very strange errors

2017-04-14 Thread Suliman via Digitalmars-d-learn

On Friday, 14 April 2017 at 09:51:55 UTC, Suliman wrote:

But I tested it on 2.073.0 too

Not 2.073.0 but v2.073.2


I checked v2.073.1 too and he reported that it's buildable with 
v2.073.1 on his PC.


Any ideas?


Re: Can't build simple project. Very strange errors

2017-04-14 Thread Suliman via Digitalmars-d-learn

But I tested it on 2.073.0 too

Not 2.073.0 but v2.073.2




Can't build simple project. Very strange errors

2017-04-14 Thread Suliman via Digitalmars-d-learn
I am getting very strange bug on very simple project. Here is 
sources http://rgho.st/7j5LQLZxb (blue button for downloading).


On: dub build I am getting error:

Unexpected OPTLINK Termination at EIP=0040F60A
EAX=0393 EBX=00438C70 ECX=0EE6 EDX=02CE
ESI=0104 EDI=03930468 EBP=0019FF38 ESP=0019FEF0
First=00402000

on: dub build --compiler=ldc2
It's buildable, but I am getting error on execution. The error 
says that file is corrupted.


If comment mysql driver. database.d:

import std.stdio;
import std.string;
import core.thread;
import ddb.postgres;
// import mysql; // <-- here
import vibe.d;
import config;

the project begin buildable with dmd and ldc2 and run ok.

I haven't seen such error before. I tried to clean


link

OPTLINK (R) for Win32  Release 8.00.17


DMD32 D Compiler v2.074.0

But I tested it on 2.073.0 too

Also I tried to cleanup folder:
AppData\Roaming\dub

but it did not help :(

Any ideas?

Windows 10



Re: Single exe vibe.d app

2017-04-11 Thread Suliman via Digitalmars-d-learn

On Friday, 7 April 2017 at 07:15:44 UTC, rikki cattermole wrote:
I'm going to give you a very bad but still a good place to 
begin with explanation.


So, what is an executable? Well in modern operating systems 
that is a file with a very complex structure inside, like 
PE-COFF or ELF. It has a bunch of things as part of this, a 
dynamic relocation table, sections and symbols.


Now, there is a very important symbol it provides a "main" 
function. Normally the libc takes ownership of this and then on 
calls to the c-main that we all know and love (druntime uses 
this and then passes it to another symbol called _Dmain).


What is the difference between a shared library and an 
executable? Well not much, no main function for starters 
(although Win32 based ones do have something like it in its 
place) and a couple of attributes stored in the file.


Executables like shared libraries are final binaries, they 
cannot be further linked with, at least with the most common 
formats + linkers anyway.


You asked about the difference between a static library and a 
shared library, it isn't quite the right comparison. You should 
be asking about static libraries versus object files. In 
essence a static library is just a group of object files. Not 
too complicated.


Ok, but what about Go? I have heard that it's compile all code to 
single exe? What is the way it's done there?


Re: Single exe vibe.d app

2017-04-07 Thread Suliman via Digitalmars-d-learn

On Thursday, 6 April 2017 at 17:39:15 UTC, Stefan Koch wrote:

On Wednesday, 5 April 2017 at 12:13:38 UTC, Satoshi wrote:

Hi,
How can I build single exe application with vibe.d (windows)?
now it require zlib.dll, libeay32.dll and ssleay32.dll

But I need it as single app.


One solution would be to compile vibe.d without ssl support
that way it will not need libeay32 and ssleay32

It should not need zlib, really as zlib is already linked into 
phobos.


Could anybody give very easy explanation about what different 
between static and dynamic libs. I read a lot of information that 
dynamic lib allow to loading at runtime and bla-bla-bla, but 
still do not understand what different between compilation at 
dynamic and static lib.


For example:
1. Does every lib can be compiler as static and as dynamic?
2. Can already compiled lib be converted to from static to 
dynamic and vise-versa.
3. If I have any dynamic lib, the only way is distribute it with 
app (or use import) or there is way to embed code from it to app?


Personaly I like if I can get single bin without any external 
dependence. In a lot of cases size do not important, it's better 
to have single bin, than heap of libs.


  1   2   3   4   5   >