Re: What is PostgreSQL driver is most stable?

2017-03-15 Thread Suliman via Digitalmars-d-learn
The retrieval of records is done via the execution of a (prepared) sql query, that returns a range object (PGResultSet), and the element of that range is the DBRow, in one of its form. So, basically, the elements are retrieved on demand while you popFront that range, leveraging what the

Re: [vibe.d] How to create authentication system via REST interface?

2017-03-15 Thread Suliman via Digitalmars-d-learn
On Wednesday, 15 March 2017 at 13:24:07 UTC, NX wrote: I'm trying to understand how to create some json-rest api that would return data (in json format) related to that specific logged in user. I see the documentation covers these but I'm totally new to vibe.d so can't quite figure out putting

Re: What is PostgreSQL driver is most stable?

2017-03-15 Thread Suliman via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 13:36:04 UTC, Daniel Kozak wrote: Dne 14.3.2017 v 14:21 Daniel Kozak napsal(a): Dne 14.3.2017 v 14:13 Suliman via Digitalmars-d-learn napsal(a): I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc

Re: What is PostgreSQL driver is most stable?

2017-03-14 Thread Suliman via Digitalmars-d-learn
On Tuesday, 14 March 2017 at 13:21:39 UTC, Paolo Invernizzi wrote: On Tuesday, 14 March 2017 at 13:13:31 UTC, Suliman wrote: I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL

What is PostgreSQL driver is most stable?

2017-03-14 Thread Suliman via Digitalmars-d-learn
I need to develop App that should work on Linux and Windows. It need PostgreSQL driver. I tried Vadim's ddbc for PostgreSQL but it's fail on x64 version of PostgreSQL and possible will not on x64 PG on Linux (I can't test it now). Could anybody advice me good driver without problems? I seen

Re: Where do you test syntax of D regexp online?

2017-03-10 Thread Suliman via Digitalmars-d-learn
On Friday, 10 March 2017 at 14:36:48 UTC, Suliman wrote: On Thursday, 9 March 2017 at 16:47:18 UTC, Adam D. Ruppe wrote: On Thursday, 9 March 2017 at 16:40:13 UTC, Suliman wrote: How should I write to file result without \r\n\ symbols? auto x = content.matchFirst(bigCodeBlock); File f =

Re: Where do you test syntax of D regexp online?

2017-03-10 Thread Suliman via Digitalmars-d-learn
On Thursday, 9 March 2017 at 16:47:18 UTC, Adam D. Ruppe wrote: On Thursday, 9 March 2017 at 16:40:13 UTC, Suliman wrote: How should I write to file result without \r\n\ symbols? auto x = content.matchFirst(bigCodeBlock); File f = File("foo.txt", "w"); f.write(x); Just f.write(x[0]); to

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
On Thursday, 9 March 2017 at 16:23:23 UTC, Adam D. Ruppe wrote: On Thursday, 9 March 2017 at 16:14:28 UTC, Suliman wrote: But now output is: [["```\r\nvoid foo()\r\n{\r\n\twriteln(\"ppp\");\r\n}\r\n```"]] But I do not \r\n\ symbols... That's just the writeln array formatter. The matchFirst

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
Adding "r" helped: auto bigCodeBlock = regex(r"`{3}[\s\S]*?`{3}"); But now output is: [["```\r\nvoid foo()\r\n{\r\n\twriteln(\"ppp\");\r\n}\r\n```"]] But I do not \r\n\ symbols...

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
On Thursday, 9 March 2017 at 15:22:00 UTC, rikki cattermole wrote: On 10/03/2017 4:17 AM, Suliman wrote: I would use dpaste and write a quick script but here is where I think your problem is: regex("/.*/g") It should be: regex(".*", "g") As per[0]. [0]

Re: Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
I would use dpaste and write a quick script but here is where I think your problem is: regex("/.*/g") It should be: regex(".*", "g") As per[0]. [0] http://dlang.org/phobos/std_regex.html#.regex Sorry, but what regexp are you talking? There is nothing like: `regex("/.*/g")` in my code...

Where do you test syntax of D regexp online?

2017-03-09 Thread Suliman via Digitalmars-d-learn
I wrote two regexp: auto inlineCodeBlock = regex("`(.*?)`"); // --> `(.*?)` auto bigCodeBlock = regex("/`{3}[\\s\\S]*?`{3}/g"); // --> `{3}[\s\S]*?`{3} First for for selection inline code block. Second for multi-line: #Header my

Question about vibe.conf file

2017-03-05 Thread Suliman via Digitalmars-d-learn
I had seen some mentions about `vibe.conf` file in vibed docs. But can't understand it's structure and find examples of it's usage.

Re: Can't rending DT template

2017-02-26 Thread Suliman via Digitalmars-d-learn
On Sunday, 26 February 2017 at 12:31:21 UTC, Suliman wrote: It's look like wrong error, because project is buildable. So I have only one question. Can I do response not in .dt, but in .html? It's seems that serveStaticFiles is only one normal way to get it work.

Re: Can't rending DT template

2017-02-26 Thread Suliman via Digitalmars-d-learn
It's look like wrong error, because project is buildable. So I have only one question. Can I do response not in .dt, but in .html?

Can't rending DT template

2017-02-26 Thread Suliman via Digitalmars-d-learn
I have this code: module pages; import vibe.d; import database; import vibe.web.web; class MyPages { @path("/page1") void getPage() { render!("home.dt"); } } The error: https://snag.gy/PtNeSs.jpg Error: template instance vibe.web.web.render!"home.dt".render!("pages",

Re: Vibe.d: Listening to port 8080 on external device doesn't work

2017-02-22 Thread Suliman via Digitalmars-d-learn
On Wednesday, 22 February 2017 at 00:38:30 UTC, aberba wrote: Using vibe.d, I bind to port 8080 at 127.0.0.1 but I can't access server on my phone through hotspot using the external IP from ip addr on Linux. But 127.0.0 running Apache server works. Don't if its vibe.d or OS (ubuntu 14.04)

Static array size?

2017-02-09 Thread Suliman via Digitalmars-d-learn
Docs says that: "The total size of a static array cannot exceed 16Mb." But when I am creation array of: int [1000_000] x; // 1000_000 is equal ~ 0,95MB app crush on start. Should it's reserve this memory with guaranty? I mean that after app start it should take +0.95MB of RAM in task manager.

Re: The reason of vibed slow down (request timeout)

2017-02-04 Thread Suliman via Digitalmars-d-learn
On Friday, 3 February 2017 at 07:44:15 UTC, crimaniak wrote: On Friday, 3 February 2017 at 06:46:37 UTC, Suliman wrote: If I open it's from VPS (as localhost:8080) it's work same as from Internet (no do not open at all). If problem is reproducible on localhost - very good, just debug it. If

Re: Fiber overhead

2017-02-04 Thread Suliman via Digitalmars-d-learn
On Saturday, 4 February 2017 at 06:54:01 UTC, Ali Çehreli wrote: On 02/03/2017 08:47 PM, Profile Anaysis wrote: What is the overhead of using a fiber? The performance overhead of call() and yield() are comparable to function calls because it's simply a few register assignments in each case.

The reason of vibed slow down (request timeout)

2017-02-02 Thread Suliman via Digitalmars-d-learn
I have simple web-app. Server part is based on vibed http://194.87.235.42:8080/ I can't understand the reason of issue. after some days of work when I trying to open it in web-browser it's begin opening very slooowly, or like now does not opens at all. On mobile web-browser I am getting

Re: Convert struct to set of fields and pass it's to constructor

2017-02-01 Thread Suliman via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 13:51:28 UTC, Minty Fresh wrote: On Wednesday, 1 February 2017 at 13:37:27 UTC, Suliman wrote: Class constructor accept only set if fields like this(string login, string pass) Can I create structure, fill it, and than pass to constructor? Like this: ``` import

Convert struct to set of fields and pass it's to constructor

2017-02-01 Thread Suliman via Digitalmars-d-learn
Class constructor accept only set if fields like this(string login, string pass) Can I create structure, fill it, and than pass to constructor? Like this: ``` import std.stdio; struct ConnectSettings { string login; string pass; }; ConnectSettings cs; void main() { cs.login =

Re: Can't find the reason of issue: "std.file.FileException@std\file.d(360): path/to/file.conf:"

2017-02-01 Thread Suliman via Digitalmars-d-learn
Not even issue, but unhandled exception when access to nonexistent file.

Re: Can't find the reason of issue: "std.file.FileException@std\file.d(360): path/to/file.conf:"

2017-02-01 Thread Suliman via Digitalmars-d-learn
On Wednesday, 1 February 2017 at 11:39:46 UTC, Suliman wrote: Full error log: 0x00580A4D in @trusted bool std.file.cenforce!(bool).cenforce(bool, const(char)[], const(wchar)*, immutable(char)[], uint) 0x00412AB6 in @safe void[] std.file.read!(immutable(char)[]).read(immutable(char)[], uint)

Re: Can't find the reason of issue: "std.file.FileException@std\file.d(360): path/to/file.conf:"

2017-02-01 Thread Suliman via Digitalmars-d-learn
Full error log: 0x00580A4D in @trusted bool std.file.cenforce!(bool).cenforce(bool, const(char)[], const(wchar)*, immutable(char)[], uint) 0x00412AB6 in @safe void[] std.file.read!(immutable(char)[]).read(immutable(char)[], uint) at C:\D\dmd2\windows\bin\..\..\src\phobos\std\file.d(229)

Can't find the reason of issue: "std.file.FileException@std\file.d(360): path/to/file.conf:"

2017-02-01 Thread Suliman via Digitalmars-d-learn
After building vibed project and running it I am getting error: "std.file.FileException@std\file.d(360): path/to/file.conf: Системе не удается найти указанный путь." (System can't find selected path) I even do not understand where is the error... It's do not seems that it's vibed issue.

Re: Why fatal log throw object.Error@(0) on console?

2017-01-30 Thread Suliman via Digitalmars-d-learn
I found in the docs mention "If data is logged with LogLevel fatal by default an Error will be thrown.". But what the reason of such behavior?

Why fatal log throw object.Error@(0) on console?

2017-01-30 Thread Suliman via Digitalmars-d-learn
import std.stdio; import std.experimental.logger; void main() { sharedLog = new FileLogger("New_Default_Log_File.log"); fatal("Fatal error: "); } All other log-levels write as expected log files, but `fatal` throw on console: app.exe object.Error@(0): A fatal log message

When I should create structures with new keywords?

2017-01-26 Thread Suliman via Digitalmars-d-learn
In the past I asked Adam about when I should use keyword `new` with structures and got next answer: "The File in the first one is put on the stack as a reference counted local object whereas the second one would be on the garbage collected heap, which often isn't what you want for files since

Re: Bug in documentation or misunderstanding it?

2017-01-26 Thread Suliman via Digitalmars-d-learn
On Thursday, 26 January 2017 at 18:42:29 UTC, Suliman wrote: On Thursday, 26 January 2017 at 17:52:24 UTC, H. S. Teoh wrote: On Thu, Jan 26, 2017 at 05:38:59PM +, Suliman via Digitalmars-d-learn wrote: I read docs and can't understand what's wrong. Or I am do not understand

Re: Bug in documentation or misunderstanding it?

2017-01-26 Thread Suliman via Digitalmars-d-learn
On Thursday, 26 January 2017 at 17:52:24 UTC, H. S. Teoh wrote: On Thu, Jan 26, 2017 at 05:38:59PM +, Suliman via Digitalmars-d-learn wrote: I read docs and can't understand what's wrong. Or I am do not understand it, or there is come mistake. Let's look at function https://dlang.org

Bug in documentation or misunderstanding it?

2017-01-26 Thread Suliman via Digitalmars-d-learn
I read docs and can't understand what's wrong. Or I am do not understand it, or there is come mistake. Let's look at function https://dlang.org/phobos/std_stdio.html#.File.byLine auto byLine(Terminator = char, Char = char)(KeepTerminator keepTerminator = No.keepTerminator, Terminator

Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
You have *two* distinct strings here. Yes, I understand, I am trying to find out how it's work on low level. Any ideas why zero is used?

Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
On Sunday, 22 January 2017 at 15:51:01 UTC, Suliman wrote: string str = "abc"; writeln(str.ptr); str = "def"; writeln("last data: ", *(str.ptr)); writeln("old data: ", *(str.ptr-1)); // print nothing writeln("old data: ", *(str.ptr-2)); // print c

Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
string str = "abc"; writeln(str.ptr); str = "def"; writeln("last data: ", *(str.ptr)); writeln("old data: ", *(str.ptr-1)); // print nothing writeln("old data: ", *(str.ptr-2)); // print c It's look like that there is some gap between data, because

Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
Supported answer: you don't, it has infinite lifetime and you're claiming it is immutable, but then trying to pull the memory out from under it! The supported solution is simply to let the garbage collector manage it. But.. //GC.free(str_ptr.ptr); // Error: function core.memory.GC.free

Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
str_ptr.ptr returns exactly the same thing as str.ptr or (*str_ptr).ptr, a pointer to the contents. When you write str_ptr, you print the pointer to the container. So str.ptr is just shortcut? Ok, but how to free memory from first located value (from `aaa`)? I changed my code to next:

Re: Can't understand if deallocation happens?

2017-01-22 Thread Suliman via Digitalmars-d-learn
You do not append to anything, only overwrite it. There is no reallocation because "aaa".length == "bbb".length. I changed my code to: str_ptr.length +=1; str[] = ""[]; But now it's print length 4 before and after writing "bbb" to `str`. I expected that size will be 3+4=7.

Re: What do you use to generate documentation?

2017-01-19 Thread Suliman via Digitalmars-d-learn
On Thursday, 19 January 2017 at 18:09:20 UTC, Basile B. wrote: On Thursday, 19 January 2017 at 15:20:37 UTC, Suliman wrote: What do dflag: `-c do not link`. Should I pass it during the generation of the docs? dub is append it's automatically, but if I want to generate new docs every rebuild of

Re: What do you use to generate documentation?

2017-01-19 Thread Suliman via Digitalmars-d-learn
What do dflag: `-c do not link`. Should I pass it during the generation of the docs? dub is append it's automatically, but if I want to generate new docs every rebuild of app what is the reason to use this flag?

Re: Why my app require MSVCR120.dll?

2017-01-18 Thread Suliman via Digitalmars-d-learn
On Wednesday, 18 January 2017 at 09:54:43 UTC, Suliman wrote: On Friday, 6 November 2015 at 18:34:45 UTC, Cauterite wrote: On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote: On Windows 7 it's work fine. On Windows 10 (clean install) it's do not start and require MSVCR120.dll D

Re: Why my app require MSVCR120.dll?

2017-01-18 Thread Suliman via Digitalmars-d-learn
On Friday, 6 November 2015 at 18:34:45 UTC, Cauterite wrote: On Friday, 6 November 2015 at 13:16:46 UTC, Suliman wrote: On Windows 7 it's work fine. On Windows 10 (clean install) it's do not start and require MSVCR120.dll D doesn't make particularly heavy use of the C runtime, so there's a

Re: How to detect free/unfree memory segments?

2016-12-23 Thread Suliman via Digitalmars-d-learn
On Saturday, 24 December 2016 at 01:15:43 UTC, jkpl wrote: On Friday, 23 December 2016 at 06:18:02 UTC, Suliman wrote: I would like to visualize how GC works and display free/not free memory segments. How I can understand which of them are used and which not? Could anybody explain what

function is not callable using argument types ()

2016-12-10 Thread Suliman via Digitalmars-d-learn
import std.stdio; import std.concurrency; void main() { void sp(int i) { receive((int i) { writeln("i: ", i); }); } auto r = new Generator!int( { foreach(i; 1 .. 10) yield(i); });

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
As an aside, for security reasons you should use a prepared statement. Even if it's server-side code and there is no any iteration with user data (they come as JSON) Also, this is a decent usecase for scope(exit) but it should be put earlier in the function. Am I right understand that

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
Looks like you forgot a call to format before the opening parenthesis. should be: string sqlinsert = format(`INSERT INTO usersshapes (userlogin, uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', '%s') `, login, uploading_date, geometry_type, data); because what ends up happening

Re: Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
On Sunday, 27 November 2016 at 11:21:58 UTC, drug007 wrote: On 27.11.2016 14:07, Suliman wrote: I am getting deprecation message: "Using the result of a comma expression is deprecated" on this code: string sqlinsert = (`INSERT INTO usersshapes (userlogin, uploading_date, geometry_type,

Using the result of a comma expression is deprecated

2016-11-27 Thread Suliman via Digitalmars-d-learn
I am getting deprecation message: "Using the result of a comma expression is deprecated" on this code: string sqlinsert = (`INSERT INTO usersshapes (userlogin, uploading_date, geometry_type, data) VALUES ('%s', '%s', '%s', '%s') `, login, uploading_date, geometry_type, data); What's wrong

Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
On Thursday, 17 November 2016 at 18:02:02 UTC, Jesse Phillips wrote: On Thursday, 17 November 2016 at 17:54:23 UTC, Suliman wrote: Ok, but when the logger class may be more helpful that function usage? You'd use the logger class when you need to make customizations or have multiple logging

Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
On Thursday, 17 November 2016 at 17:45:31 UTC, Stefan Koch wrote: On Thursday, 17 November 2016 at 17:42:44 UTC, Suliman wrote: On Thursday, 17 November 2016 at 16:46:37 UTC, Steven Schveighoffer wrote: On 11/17/16 11:28 AM, Suliman wrote: [...] D does not require classes to write

Re: Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
On Thursday, 17 November 2016 at 16:46:37 UTC, Steven Schveighoffer wrote: On 11/17/16 11:28 AM, Suliman wrote: There is some functions that can be called without creation of class. For example: http://vibed.org/api/vibe.core.log/ As I understand I can create write log in two way. First

Why some function are class-less?

2016-11-17 Thread Suliman via Digitalmars-d-learn
There is some functions that can be called without creation of class. For example: http://vibed.org/api/vibe.core.log/ As I understand I can create write log in two way. First create instance of Logger, second simply call function. Why it's done so? Just as shortcut? But is I create class

Re: Question about __treats

2016-09-21 Thread Suliman via Digitalmars-d-learn
On Wednesday, 21 September 2016 at 07:09:01 UTC, rikki cattermole wrote: On 21/09/2016 7:06 PM, Suliman wrote: It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't understand difference

Question about __treats

2016-09-21 Thread Suliman via Digitalmars-d-learn
It's seems that __treats is language keyword that help to get info from compile-time. But there is also lib named std.traits and I can't understand difference https://dlang.org/spec/traits.html https://dlang.org/phobos/std_traits.html Could you explain the difference?

Re: dub: how to update package?

2016-09-17 Thread Suliman via Digitalmars-d-learn
On Saturday, 17 September 2016 at 07:25:29 UTC, Intersteller wrote: I have a dub project, is there a way to update to get the latest package? dub upgrade

How it's better to store data from DB?

2016-09-05 Thread Suliman via Digitalmars-d-learn
Usually I am storing daba from DB as array of structures. Something like: struct MyData { int id; string name; int age; } MyData mydata; Then I am creating array of structures: MyData [] mydatas; And fill data in my code. Then append it to `mydatas` to get it iterable. But is it's

Re: Few questions about concurrency

2016-08-27 Thread Suliman via Digitalmars-d-learn
Message passing is an alternative to relying on globals + mutex's. In the end its implemented by a global + stack FIFO (mailbox). Where it's better? Could you give an example? Ring transition e.g. system calls are not all that expensive. Its what the kernel does with that system call that is

Few questions about concurrency

2016-08-27 Thread Suliman via Digitalmars-d-learn
Hello! I am still attempt to better understand how concurrency works. I read a lot of info but still misunderstood some key-points. Here is my thought about it and questions: 1. There is OS threads. Context-switching is very expensive because during it we should to save ALL CPU registers to

Is it's possible to install DMD/LDC/GDC on CoreOS?

2016-08-21 Thread Suliman via Digitalmars-d-learn
I would like to create small VPS instance with Linux distrib on VPS. Can I use CoreOS as image? Would it possible to install dlang there?

When I should to call destroy?

2016-07-29 Thread Suliman via Digitalmars-d-learn
Use the `destroy` function to finalize an object by calling its destructor. The memory of the object is not immediately deallocated, instead the GC will collect the memory of the object at an undetermined point after finalization: class Foo { int x; this() { x = 1; } } Foo foo = new Foo;

Re: Question about destructor of database and multiple use access

2016-07-29 Thread Suliman via Digitalmars-d-learn
So my last variant is right? How can I inspect code, to better understand how GC works? Also where I can find idiomatic code with comments? Just to read for better understand design solutions.

Re: Question about destructor of database and multiple use access

2016-07-28 Thread Suliman via Digitalmars-d-learn
class GDB { Config config; MySQLDriver driver; DataSource ds; Connection conn; this(Config config) { this.config = config; driver = new MySQLDriver(); string[string] params; string url =

Question about destructor of database and multiple use access

2016-07-28 Thread Suliman via Digitalmars-d-learn
I have for next queston. For example I have class for working with DB (I am using ddbc driver). I put some variables as class fields, and init them in constructor: class GDB { Statement stmt; Config config; MySQLDriver driver; DataSource ds;

Re: Check of point inside/outside polygon

2016-07-27 Thread Suliman via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 12:47:14 UTC, chmike wrote: On Wednesday, 27 July 2016 at 09:39:18 UTC, Suliman wrote: ... Big thanks! Ehm... Now I should add iteration on array of points in first and second polygon? If it's not hard for you could you show how it should look please. Sorry, I

Re: Check of point inside/outside polygon

2016-07-27 Thread Suliman via Digitalmars-d-learn
On Wednesday, 27 July 2016 at 08:40:15 UTC, chmike wrote: The algorithm is to draw a horizontal (or vertical) half line starting at your point and count the number of polygon edges crossed by the line. If that number is even, the point is outside the polygon, if it's odd, the point is inside.

Re: Check of point inside/outside polygon

2016-07-26 Thread Suliman via Digitalmars-d-learn
I have arbitrary polygon. I need any solution. Performance is does not matter at current moment.

Check of point inside/outside polygon

2016-07-26 Thread Suliman via Digitalmars-d-learn
Ideally I need algorithm that can return bool if one polygon overlapped/intersected by another. But I do not know math. After some googling I found topic on SO[1] about point inside/outside polygon. It's not directly what I need, but as temporal solution would be enough. Maybe somebody

Re: Singleton Pattern

2016-07-10 Thread Suliman via Digitalmars-d-learn
On Saturday, 9 July 2016 at 20:47:32 UTC, Ali Çehreli wrote: On 07/09/2016 01:35 PM, Suliman wrote: > On Thursday, 5 January 2012 at 22:53:12 UTC, Ali Çehreli wrote: >> On 01/05/2012 02:15 PM, asm wrote: >>> how can i implementing the singleton pattern in D? >> >> Is singleton still alive? ;)

Re: Singleton Pattern

2016-07-09 Thread Suliman via Digitalmars-d-learn
On Thursday, 5 January 2012 at 22:53:12 UTC, Ali Çehreli wrote: On 01/05/2012 02:15 PM, asm wrote: how can i implementing the singleton pattern in D? Is singleton still alive? ;) An idea is to instantiate the object in the module's static this(). Ali Yeah, same question, what difference

Why I can't catch the exception?

2016-06-05 Thread Suliman via Digitalmars-d-learn
I really can't understand why try-catch block do not handle exception. digit 1 is printing, so exception is accrue after it, but why nothing in catch block? http://img.ctrlv.in/img/16/06/05/57546861d8e81.png Here is my code: void dbSetup() { try { //getcwd do not return

Re: What can cause error: Previous Definition Different

2016-05-04 Thread Suliman via Digitalmars-d-learn
On Wednesday, 4 May 2016 at 10:01:54 UTC, Suliman wrote: After some minor modification of my code I begun to get error: Error 1: Previous Definition Different : _D3app14onlinetestdataFC4vibe4http6server17HTTPServerRequestC4vibe4http6server18HTTPServerResponseZv Here is my code:

What can cause error: Previous Definition Different

2016-05-04 Thread Suliman via Digitalmars-d-learn
After some minor modification of my code I begun to get error: Error 1: Previous Definition Different : _D3app14onlinetestdataFC4vibe4http6server17HTTPServerRequestC4vibe4http6server18HTTPServerResponseZv Here is my code: https://gist.github.com/bubnenkoff/db0632bb14eebb7690b6563c47395831

Re: Why I can't pass to datetime.benchmark function with parameters?

2016-04-23 Thread Suliman via Digitalmars-d-learn
In the third example you're providing an integer as the function to benchmark, and foo is never mentioned. My error. I mean it should be: auto r = benchmark!(foo(4))(1); But thanks for answer!

Why I can't pass to datetime.benchmark function with parameters?

2016-04-23 Thread Suliman via Digitalmars-d-learn
Working: void main() { auto r = benchmark!(foo)(1); } void foo() { } Do not working: void main() { auto r = benchmark!(foo())(1); } void foo() { } Error: expression foo() is void and has no value Do not working: void main() { auto r = benchmark!(4)(1); } void foo(int i) {

Re: Which application is much suited and which is not.

2016-04-17 Thread Suliman via Digitalmars-d-learn
On Saturday, 16 April 2016 at 18:13:57 UTC, Bauss wrote: On Saturday, 16 April 2016 at 14:08:05 UTC, newB wrote: Let's say you have decided to use D programming language. For what kind of applications would you choose D programming language and For what kind of applications you won't

Re: Need help with bytea data type from PostgreSQL.

2016-04-12 Thread Suliman via Digitalmars-d-learn
With: x = row[0].as!(ubyte[]); I am getting error: core.exception.AssertError@C:\D\dmd2\windows\bin\..\..\src\phobos\std\typecons.d(1920): Called `get' on null Nullable!ubyte[].

Need help with bytea data type from PostgreSQL.

2016-04-12 Thread Suliman via Digitalmars-d-learn
I am still trying to get work any of PostgreSQL drivers. For last few day I had test all of drivers. All of them are _very_ buggy! Just few of them have support of `bytea` data type, that use for binary blobs. But support does not mean that it's work. Now I am trying to get

Re: What is best way to get see function from separate file

2016-04-10 Thread Suliman via Digitalmars-d-learn
You could pass an argument of type FileLogger (probably better a pointer?) foo ( FileLogger log ) { } I like it. Am i right understand that it prevent creation unneeded of new instance of logger? And what problems I can get if I will create new instance of logger in every stand alone

Re: What is best way to get see function from separate file

2016-04-10 Thread Suliman via Digitalmars-d-learn
Sorry for wrong posting! I have got logger instance in App.d void main() { ... FileLogger fLogger = new FileLogger("ErrorLog.txt"); foo(); } utils.d: foo() { // I need logging here } Also I have file utils.d that include stand-alone functions that is not in classes. In one of them I need

What is best way to get see function from separate file

2016-04-10 Thread Suliman via Digitalmars-d-learn
I have got logger instance in App.d void main() { FileLogger fLogger = new FileLogger("ErrorLog.txt");

Re: VibeCustomMain not working

2016-04-07 Thread Suliman via Digitalmars-d-learn
dup upgdare dub upgdare

Re: VibeCustomMain not working

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:01:59 UTC, Jerry wrote: Hello, I am trying to use vibe with DMD 2.67, dub and windows. But in some way the default main function is sneaking in my build system even when I'm using VibeCustomMain version. Main file: import vibe.vibe; void main() {

Re: How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:43:54 UTC, rikki cattermole wrote: On 08/04/2016 12:39 AM, Suliman wrote: On Thursday, 7 April 2016 at 12:30:59 UTC, rikki cattermole wrote: On 08/04/2016 12:19 AM, Kagamin wrote: Create a range that would remove the newline characters from string, then decode

How to convert PostgreSQL bytea HEX value to byte[] ?

2016-04-07 Thread Suliman via Digitalmars-d-learn
I need to extract binary blob from PostgreSQL. It's input/output by default work in hex mode. http://www.postgresql.org/docs/current/static/datatype-binary.html I need to extract data and write them on FS as normal file (byte [] I suppose). Here is my question on SO

Re: How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:30:59 UTC, rikki cattermole wrote: On 08/04/2016 12:19 AM, Kagamin wrote: Create a range that would remove the newline characters from string, then decode from that. Can confirm, its \n and \r that is causing the problems here. with:

Re: How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 12:19:48 UTC, Kagamin wrote: Create a range that would remove the newline characters from string, then decode from that. std.file.write("output.png", Base64.decode(myimg.chomp)); The same error

Re: How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
On Thursday, 7 April 2016 at 11:59:09 UTC, rikki cattermole wrote: On 07/04/2016 11:49 PM, Suliman wrote: It's look like my data have padding that cause crush on function: std.file.write("output.png", Base64.decode(myimg)); Invalid character: It's look like I should to use template

How to set padding for base64 encoding

2016-04-07 Thread Suliman via Digitalmars-d-learn
It's look like my data have padding that cause crush on function: std.file.write("output.png", Base64.decode(myimg)); Invalid character: It's look like I should to use template function, but I can't figure out how to use it. Could anybody show example? My code:

Build release and debug with dub

2016-04-06 Thread Suliman via Digitalmars-d-learn
Is it's possible to make rule, that allow to build two version of App? One release and one debug at same time. I looked at "buildTypes" https://code.dlang.org/package-format?lang=json But it's not possible to set different names for output files. I want to build App.exe and AppDebug.exe after

What is the best way to store bitarray (blob) for pasting in database?

2016-04-06 Thread Suliman via Digitalmars-d-learn
I have next task. There is PostgreSQL DB. With field like: id, mydata. mydata - is binary blob. It can be 10MB or even more. I need load all data from PostgreSQL to SQLLite. I decided ti create struct that and fill it with data. And then do INSERT operation in sqllite. But I do not know is

Re: PostgreSQL. Unknown parameter of configuration : "autocommit"

2016-04-05 Thread Suliman via Digitalmars-d-learn
On Tuesday, 5 April 2016 at 07:53:20 UTC, Suliman wrote: Is there anybody who have success connect to PostgreSQL with ddbc? I am getting next error: https://github.com/buggins/ddbc/issues/22 Look like driver do not support PG 9.5 http://www.symmetricds.org/issues/view.php?id=2439

PostgreSQL. Unknown parameter of configuration : "autocommit"

2016-04-05 Thread Suliman via Digitalmars-d-learn
Is there anybody who have success connect to PostgreSQL with ddbc? I am getting next error: https://github.com/buggins/ddbc/issues/22

Re: Is there anybody who used FireBird DB?

2016-03-31 Thread Suliman via Digitalmars-d-learn
On Thursday, 31 March 2016 at 08:53:46 UTC, Kagamin wrote: AFAIK when you request a string, whatever value is there gets converted to string. Or you can just add code to extract blobs, that would be less effort than writing everything from scratch. I have contact with it's developer. Hope for

Re: Is there anybody who used FireBird DB?

2016-03-30 Thread Suliman via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 20:23:13 UTC, Kagamin wrote: You can also look here https://github.com/cruisercoder/dstddb/blob/master/src/std/database/odbc/database.d for an example of accessing ODBC from D (only strings are supported so far). Does ita mean that I would not able to select

Re: Is there anybody who used FireBird DB?

2016-03-30 Thread Suliman via Digitalmars-d-learn
On Wednesday, 30 March 2016 at 18:31:35 UTC, Kagamin wrote: Also there's ODBC driver http://www.firebirdsql.org/en/devel-odbc-driver/ - you can use it, phobos has ODBC bindings. Where I can get the latest version? There is not any package on http://code.dlang.org/ and searching on github

Re: Is there anybody who used FireBird DB?

2016-03-30 Thread Suliman via Digitalmars-d-learn
I have found next driver http://www.ibpp.org/#what_is_ibpp Here http://sourceforge.net/projects/ibpp is link to zip package that include two exe files and ibpp.lib ibpp.h it's look like it's ass that need for binding. I tried to run htod.exe but got error: D:\Project\2016>htod.exe ibpp.h

Re: Need help with delegates and vibed

2016-03-20 Thread Suliman via Digitalmars-d-learn
The constructor for HTTPClientRequest is likely undocumented because you should not construct it yourself; vibe.d constructs it and passes it to the function you register with listenHTTP. How to understand looking at docs that it work as you saying?

Need help with delegates and vibed

2016-03-20 Thread Suliman via Digitalmars-d-learn
I can't understand how to get works delegates works from this doc http://vibed.org/api/vibe.http.client/requestHTTP I see example, but when I am looking on Prototypes I really can't figure how to use them. For example what does this mean: scope void delegate(scope HTTPClientRequest)

Re: Need help with delegates and vibed

2016-03-19 Thread Suliman via Digitalmars-d-learn
Thanks! I am understand a little bit better, but not all. ``` shared static this() { auto settings = new HTTPServerSettings; settings.port = 8080; listenHTTP(settings, ); } void handleRequest(HTTPServerRequest req, HTTPServerResponse res) { if

<    1   2   3   4   5   >