Re: Reflection on the book D web development.
& Golang has Martini which is quite easy to use, https://www.youtube.com/watch?v=tUFzdUIjVRg
Re: Reflection on the book D web development.
hunt-http has no documentation and does not looks usable to me. What looks usable is kemal & the crystal language, https://kemalcr.com/guide/
Re: Reflection on the book D web development.
It's not my related to a lack of knowledge of the d-language but the complexity of the vibe.d framework itself. What I understand are : 1: jade/diet .dt templates, inheritance,includes,markdown. 2: A simple form with POST method. Then it stops. What I find too complex: - Sessions, session data , session variables - Handler functions and delegates, compile-time reflection, prefixes, annotation. - Authentication - Validating user input This can be improved by improving documentation in very small steps. As comparison here a tutorial of ruby-flask which uses only small steps so everything can easily and completely be understood. Something like that for vibe.d would be very interesting. https://www.youtube.com/watch?v=3mwFC4SHY-Y
Reflection on the book D web development.
I bought the book "D Web Development". I understand only 20% of the book,the other 80% is way above my head. Compare, I own a book on flask development, and I understand 100% of it. Which means I can use dlang for anything except QT and serious web development ...
Re: How to use bootstrap with vibe.d.
It know it gives you nice buttons. I suppose to use it you add the bootstrap .js and .css file links to the diet templates.
How to use bootstrap with vibe.d.
(title). In flask it is "from flask_bootstrap import Bootstrap". But what do you have to do with vibe.d ?
GtkD CRUD Application
I've written the beginning but dont know how to end. What is the way to add functionality for the add,edit,delete button ? //== import gtk.Button; import gtk.Box; import gtk.Label; import gtk.Entry; import gtk.Grid; import gtk.Main; import gtk.MainWindow; import gtk.Widget; import gdk.Event: Event; import std.array: assocArray; import std.conv: to; import std.format : format; import std.range: iota, retro, drop, zip; import std.stdio: writeln; struct nameage { string name; int age; } class Row: Box { ulong index; this(nameage anameage,ulong index){ this.index=index; super(Orientation.HORIZONTAL,5); this.packStart((new Label(anameage.name)),0,0,0); this.packStart((new Label(to!string(anameage.age))),0,0,0); this.packStart((new Button("Edit")),0,0,0); this.packStart((new Button("Delete")),0,0,0); } } class MyWindow : MainWindow { Box vbox; nameage []mynameage; void quit(){ this.quit(); } void addclicked(){ } this(int sizex,int sizey){ nameage nameage1=nameage("Alain",20); nameage nameage2=nameage("Eddy",30); mynameage ~= nameage1; mynameage ~= nameage2; super("My Locate D-lang App"); setSizeRequest(sizex,sizey); setHexpand(0); addOnDestroy(delegate void(Widget w) { quit(); } ); vbox=new Box(Orientation.VERTICAL,5); foreach (ulong i,anameage;mynameage){ Row arow=new Row(anameage,i); vbox.packStart(arow,0,0,0); } Button addbutton=new Button("Add"); addbutton.addOnClicked(delegate void(Button b){addclicked();}); vbox.packStart(addbutton,0,0,0); add(vbox); showAll(); } } int main(string[] args){ int sizex=800; int sizey=600; Main.init(args); MyWindow window=new MyWindow(sizex,sizey); Main.run(); return 0; } //==
Re: vibe.d / experience / feedback
Is there an example just more functional then skeleton http server ? Sending data to the server and back .
Re: vibe.d / experience / feedback
forms.
Re: vibe.d / experience / feedback
One concept at a time. This is one of the simplest examples in vibe.d. I look for the code for the same functionality but without authentication/login. https://github.com/vibe-d/vibe.d/blob/master/examples/web/source/app.d Where are the @ lines explained ?
Re: vibe.d / experience / feedback
What is weird is that rails is THE ruby application , that flask is the python application, and that dlang can't have something like that in their standard library. An opportunity missed. On the other hand I don't understand the interest in Java/swing when there is a good working gtkd which is a good working and beautiful framework.
Re: Why does sum not work in static arrays?
Sidenote, sort also not works with static arrays.
Re: vibe.d / experience / feedback
For a framework to be successful you need at least a minimum of sample code in public domain. For vibe it is none existent. I could not even find demo code doing a redirect which is the most basic stuff. The number of books on a framework is also an indication of the success after a few years. Compare for instance to Flask or rails. Also a framework must concentrate on one task. A web framework should not care about sql. Neither a GUI framework.
Re: How to spawn a thread within a GtkD button event handler
With idle (not the editor :)) , it works perfect. Thanks for your help.
Re: How to spawn a thread within a GtkD button event handler
I'll try your example. Thanks.
Re: How to spawn a thread within a GtkD button event handler
I did not used glib.idle. Probably this is essential.
Re: How to spawn a thread within a GtkD button event handler
No use geany. The error occurs also when no editor is open. I think the gtk libraries are not meant to be used in multithreaded way, where gtk is not knowing what is happening. A process in background doing file things is no problem. It is when a process in background tries to update a lot of widgets. Probably the internal event queue of gtk gets confused.
Re: How to spawn a thread within a GtkD button event handler
The idea looked good but gtk was unhave when 1000 labels where updated by another thread.
Re: How to spawn a thread within a GtkD button event handler
I created blindly a thread and this allowed to do stuff in background. But when i passed the mainwindow as argument and did some stuff it resulted in, [xcb] Unknown sequence number while processing queue [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. Assertion failed: (!xcb_xlib_threads_sequence_lost), function poll_for_event, file xcb_io.c, line 263. Program exited with code -6
Re: How to spawn a thread within a GtkD button event handler
One thing I want to do is in an eventhandler of a button released event which takes minutes in duration to change the state of the statusbar indicating something is going on. But the statusbar is not redrawn before the evenhandler finishes. Better would be to start a new thread but D-spwawn-threads can not call member functions of the MainWindow calls so some plumbing with gtk is needed. This thread would coexist with the gtk main eventloop. The GTK docs on this look overwhelmingly complicated at first.
How to spawn a thread within a GtkD button event handler
Because when the eventhandler takes to much time the application is no longer responsive. And even a simple redraw request is not performed before ending of the thread. A small and short demo app would nice. Or guideline and direction.
Re: Efficient sort function allowing own test and swap function as parameter
On Wednesday, 7 October 2020 at 11:05:39 UTC, WebFreak001 wrote: On Tuesday, 6 October 2020 at 22:18:39 UTC, Alaindevos wrote: I have a large table consisting of two columns.One with words.Another with frequencies. I want to sort them efficiently according to the names or frequency. For this I need an efficient sort function where I can plugin my proper test of order, and proper swap. Currently I do it using an own written bubble sort that doesn't scale well. you can use std.range:zip with std.algorithm:sort: import std; void main() { string[] names = ["Bob", "Alice", "Foo", "Bar"]; int[] freq = [5, 7, 1, 6]; zip(names, freq).sort!"a[0] < b[0]"; // sort by name writeln(names); writeln(freq); zip(names, freq).sort!"a[1] < b[1]"; // sort by frequency writeln(names); writeln(freq); } This was what I was looking for. This zip combined with sort is powerful.
Re: question on dub and postgresql
I found dub.json has very important info, To name three : importPaths , libs , dependencies. When these are right you have started for 80%. Without nagging, when you begin you are however lost in the woods and it makes the impression to lose interest completely. For ease there is : targetName, targetPath, sourcePaths. What is also quite annoying is links to libraries which are unmaintained. E.g. sql-libraries where no code check-in has been done for almost ten years.
Efficient sort function allowing own test and swap function as parameter
I have a large table consisting of two columns.One with words.Another with frequencies. I want to sort them efficiently according to the names or frequency. For this I need an efficient sort function where I can plugin my proper test of order, and proper swap. Currently I do it using an own written bubble sort that doesn't scale well.
Re: It is possible to substract 5 from 3 unsigned integer
There are two subtractions possible. A machine-one which can be architecture dependent, does not have the same results on all computers, and behaves like a modulus in mathematics. A logical one. For the last one higher classes might be needed.
Re: It is possible to substract 5 from 3 unsigned integer
On Tuesday, 6 October 2020 at 12:24:56 UTC, Alaindevos wrote: Is that the expected behavior of the programmer? Opinions can differ. Feel free to elaborate. E.g. length of a string unsigned long.
It is possible to substract 5 from 3 unsigned integer
Is that the expected behavior of the programmer? Opinions can differ. Feel free to elaborate.
Re: question on dub and postgresql
Use "rangify" template to get forward range from answer Thanks, this answers the question on programmatic level. Yet I guess something is special with the answer datatype which makes foreach to fail.
Re: question on dub and postgresql
On Monday, 5 October 2020 at 14:57:53 UTC, Alaindevos wrote: answer[0][0].as!PGtext contains good data I found an answer. foreach(rownumber; answer.length.iota){ auto arow=answer[rownumber]; writeln(arow); } Yet it would be nice to know why i can't iterate directly over answer using foreach.
Re: question on dub and postgresql
answer[0][0].as!PGtext contains good data
Re: question on dub and postgresql
Just Connection worked. But how do I loop over results of a select statement. string sql=format(" SELECT * from %s ;",tablepredata); auto answer = conn.exec(sql); foreach(arow; answer){ writeln(arow); } Fails with, dub ~master: building configuration "application"... source/app.d(36,3): Error: invalid foreach aggregate answer, define opApply(), range primitives, or use .tupleof /usr/local/bin/ldc2 failed with exit code 1.
Re: question on dub and postgresql
On Monday, 5 October 2020 at 13:30:22 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 11:35:43 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc Say I want to use dpq2. Do I need to clone the git repository with "git clone ?" No, you just dub add dpq2 With dub.json: "dependencies": { "dpq2": "~>1.0.17" }, It worked. Something I ask myself is how do I pass a connection from one function to another. ... string url=format("hostaddr='127.0.0.1' port='5432' dbname='%s' user='%s' password='%s'",db,user,pass); writeln(url); Connection conn = new Connection(url); auto answer = conn.exec("SELECT version()"); writeln(answer[0][0].as!PGtext); ... myfunction(conn) void myfunction( conn) What is the type I should use for passing conn ? Maybe just Connection ?
Re: question on dub and postgresql
On Monday, 5 October 2020 at 11:35:43 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc Say I want to use dpq2. Do I need to clone the git repository with "git clone ?" No, you just dub add dpq2 With dub.json: "dependencies": { "dpq2": "~>1.0.17" }, It worked. Something I ask myself is how do I pass a connection from one function to another. ... string url=format("hostaddr='127.0.0.1' port='5432' dbname='%s' user='%s' password='%s'",db,user,pass); writeln(url); Connection conn = new Connection(url); auto answer = conn.exec("SELECT version()"); writeln(answer[0][0].as!PGtext); ... myfunction(conn) void myfunction( conn) What is the type I should use for passing conn ?
Re: question on dub and postgresql
On Monday, 5 October 2020 at 09:24:33 UTC, Mike Parker wrote: On Monday, 5 October 2020 at 09:05:16 UTC, Alaindevos wrote: [...] You don't need to install dpq2 if you are using dub to build your project. Add it as a dependency to your dub.json (or dub.sdl if you prefer that format). When you build your project, dub will download the version you configured as your dependency and compile it along with your project. [...] Thanks for this clear explanation. I'll try first using the dub tooling. PS : Manual does not look easy with different versions in the /home/myhome/.dub/packages directory.
Re: question on dub and postgresql
On Monday, 5 October 2020 at 08:54:39 UTC, Daniel Kozak wrote: On Mon, Oct 5, 2020 at 10:25 AM Alaindevos via Digitalmars-d-learn < digitalmars-d-learn@puremagic.com> wrote: Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? Yes and no. Dub is Dlang dependency solution but it is not installer as pip is As I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start. Yes if you want to use any of dub packages you need to add it as a dependency to your dub.json (dub.sdl) A name dependency solution is at least vage. How do I install , https://github.com/denizzzka/dpq2 on unix so in the code i write the .d files of that library and after compilation linked to the libary shared objects. For that shared object must be installed. How ?
Re: question on dub and postgresql
On Monday, 5 October 2020 at 08:50:53 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc Say I want to use dpq2. Do I need to clone the git repository with "git clone ?" rdmd is as expected unaware of includes and libraries needed. rdmd --build-only test.d test.d(3): Error: module `dpq2` is in file 'dpq2.d' which cannot be read import path[0] = . import path[1] = /usr/local/include/d Failed: ["/usr/local/bin/ldmd2", "-v", "-o-", "test.d", "-I."] I cloned the git repository with ,running make does nothing. There is no makefile. Dub build spits out, dub build (git)-[master]- Main package must not have target type "sourceLibrary". Cannot build.
Re: question on dub and postgresql
On Monday, 5 October 2020 at 08:47:45 UTC, Alaindevos wrote: On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc Say I want to use dpq2. Do I need to clone the git repository with "git clone ?" rdmd is as expected unaware of includes and libraries needed. rdmd --build-only test.d test.d(3): Error: module `dpq2` is in file 'dpq2.d' which cannot be read import path[0] = . import path[1] = /usr/local/include/d Failed: ["/usr/local/bin/ldmd2", "-v", "-o-", "test.d", "-I."]
Re: question on dub and postgresql
On Monday, 5 October 2020 at 08:34:37 UTC, Imperatorn wrote: On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: [...] Take a look at: https://code.dlang.org/packages/dpq2 https://code.dlang.org/packages/ddbc Say I want to use dpq2. Do I need to clone the git repository with "git clone ?"
Re: question on dub and postgresql
On Monday, 5 October 2020 at 08:24:26 UTC, Alaindevos wrote: Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? As I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start. [Cfr. in python it is just a "pip install postgres". And you're fine ] Thanks for any info. Some additional question, i struggle with. Do i run dub make dub install on git clone ? Or make , make install ? Or it depends on the package provider ? What for vibe ? Which postgresql implementation is best for retreving query results record by record ?
question on dub and postgresql
Can I say python has pip, ruby has bundle and D has dub. Meaning they perform the same function ? Or am I wrong? As I use unix the parameters for include and library are a real pain. I have totally no idea how to connect to a postgresql database. Where and how do I start to connect to a postgresql database ? I write a .d program to connect. But then I need to include the database-connection-library.d file. Where do I place it ? And link a database-connection. object file. How is it installed ? There is a only a git i can clone ? Do I need to create and edit a specific dub json config file ? It is very unclear how to start. [Cfr. in python it is just a "pip install postgres". And you're fine ] Thanks for any info.