Re: Curl, how to recieve data.

2015-10-18 Thread holo via Digitalmars-d-learn
On Sunday, 18 October 2015 at 20:12:42 UTC, sigod wrote: On Sunday, 18 October 2015 at 20:05:24 UTC, holo wrote: @sigod Actually im working on ec2 requests. Thank you for help, it is working right now. I don't know why i was trying "+=" before instead of "~=". Is it good solution to make it

Re: Curl, how to recieve data.

2015-10-18 Thread holo via Digitalmars-d-learn
@sigod Actually im working on ec2 requests. Thank you for help, it is working right now. I don't know why i was trying "+=" before instead of "~=". Is it good solution to make it such way? @Suliaman I need to collect information about my instances and put it to DB. I want to present those

Re: kxml and dub package manager.

2015-10-18 Thread holo via Digitalmars-d-learn
ok i fugure out it. When i do initiation i need to add dependencies (thought it is enough to add them to sdl file). Proper initiation should look like that: dub init projectname kxml

Re: Curl, how to recieve data.

2015-10-18 Thread holo via Digitalmars-d-learn
On Sunday, 18 October 2015 at 21:11:58 UTC, sigod wrote: On Sunday, 18 October 2015 at 21:01:05 UTC, holo wrote: On Sunday, 18 October 2015 at 20:12:42 UTC, sigod wrote: [...] I changed it to such code: ... auto client = HTTP(endpoint ~ "?" ~ canonicalQueryString);

kxml and dub package manager.

2015-10-18 Thread holo via Digitalmars-d-learn
I want to add xml support to my application so i fetched kxml library with dub but it don't want to work for me. Steps and test code: [holo@ultraxps kxml]$ cat dub.sdl name "kxml" description "A minimal D application." copyright "Copyright © 2015, holo" authors "holo" dependencies "kxml"

Re: kxml and dub package manager.

2015-10-18 Thread holo via Digitalmars-d-learn
On Monday, 19 October 2015 at 03:04:28 UTC, drug wrote: 19.10.2015 02:57, holo пишет: How to make dub to work for me? Try ``` import kxml.xml; // instead of import kxml; ``` Same: [holo@ultraxps kxml]$ dub run Performing "debug" build using dmd for x86_64. kxml ~master: building

kxml - parsing AWS API xml respond

2015-10-18 Thread holo via Digitalmars-d-learn
I'm trying to take out from AWS respond needed information. Here is cut off part of example respond: ... i-x ami-x 16 running

Re: kxml - parsing AWS API xml respond

2015-10-19 Thread holo via Digitalmars-d-learn
On Monday, 19 October 2015 at 11:53:08 UTC, Kagamin wrote: On Monday, 19 October 2015 at 04:49:25 UTC, holo wrote: Why there is needed that "//" before tag? That's an XPath expression. Need, to read about that XPaths. How to drop tags from respond? I have such result of parsing by id

Re: kxml - parsing AWS API xml respond

2015-10-19 Thread holo via Digitalmars-d-learn
Sorry i was trying to use that XPaths to take out instanceId and laounchTime but i always get an empty respond. //instanceId/launchTime" - empty //instanceId/* - empty too //instanceId.launchTime - empty too How to take instance id and variable which im interest in or few/all for

Re: kxml and dub package manager.

2015-10-19 Thread holo via Digitalmars-d-learn
On Monday, 19 October 2015 at 06:20:19 UTC, Mike Parker wrote: On Monday, 19 October 2015 at 03:33:18 UTC, holo wrote: ok i fugure out it. When i do initiation i need to add dependencies (thought it is enough to add them to sdl file). Proper initiation should look like that: dub init

Re: kxml - parsing AWS API xml respond

2015-10-19 Thread holo via Digitalmars-d-learn
On Monday, 19 October 2015 at 12:54:52 UTC, Kagamin wrote: Select parent tags and get data from their child tags like instanceId. void main() { string xmlstring = cast(string)read("test.xml"); XmlNode newdoc = xmlstring.readDocument(); XmlNode[] searchlist =

Re: Class, constructor and inherance.

2015-10-14 Thread holo via Digitalmars-d-learn
I want to ask you for advises what i could do with that class to make it looks more "pro"/elegant/build in "proper way". Probably there are lot of mistakes which all beginners are doing. eg.: Did i use interface correctly? You are reasonably close: credential sig = new sigv4(); Why are

Re: Class, constructor and inherance.

2015-10-15 Thread holo via Digitalmars-d-learn
Thank you for example. I asked about it programmers at work too - PHP guys - and they explained me how you are see usage of that interfaces in my code. They prepare for me some "skeleton" on which i will try to build my solution. Will be back if i will have some code.

Re: Class, constructor and inherance.

2015-10-15 Thread holo via Digitalmars-d-learn
I created interface IfRequestHandler it is used only by one class RequestHandlerXML right now but thanks to such solution i can create more classes with same interface which can handle it in different way.. eg second can be RequestHandlerCSVReport or RequestHandlerSendViaEmail. Is it this what

Re: kxml - parsing AWS API xml respond

2015-10-19 Thread holo via Digitalmars-d-learn
On Monday, 19 October 2015 at 16:12:56 UTC, Kagamin wrote: If you don't want parent tag, then: XmlNode[] searchlist2 = newdoc.parseXPath("//launchTime"); I wanted parent tag, i think. I almost figure out what i needed, but getCData stops working :/ void main() { string xmlstring =

Re: kxml - parsing AWS API xml respond

2015-10-19 Thread holo via Digitalmars-d-learn
I have no idea what i'm doing, but i did it (i just choose 1 element of array): void main() { string xmlstring = cast(string)read("test.xml"); XmlNode newdoc = xmlstring.readDocument(); XmlNode[] searchlist = newdoc.parseXPath(`//instancesSet/item`); foreach(list;

Re: kxml - parsing AWS API xml respond

2015-10-20 Thread holo via Digitalmars-d-learn
On Tuesday, 20 October 2015 at 13:23:47 UTC, opticron wrote: I think part of the issue here is that holo isn't quite sure of what information [s]he needs out of the XML reply and how to do that with XPath. The first post mentioned getting instanceId and launchTime, so I'll start there using

Curl, how to recieve data.

2015-10-18 Thread holo via Digitalmars-d-learn
I'm trying to receive data from curl request my sample code looks like that: ... auto client = HTTP(endpoint ~ "?" ~ canonicalQueryString); client.method = HTTP.Method.get; client.addRequestHeader("x-amz-date", xamztime);

Re: Class, constructor and inherance.

2015-10-14 Thread holo via Digitalmars-d-learn
Just some ideas: interface RequestResult { ... } RequestResult go(string[string] requestParameters) Basically it is same what you wrote in one of first posts. Interface is for declaration of methods which need to be implemented in class. How in that case is it possible to return

Re: Class, constructor and inherance.

2015-10-14 Thread holo via Digitalmars-d-learn
Please again, any example? I'm trying to figure out how it should be done but i don't have any base from which i can build some solution. #!/usr/bin/rdmd import std.stdio; interface RequestResult { int add (int x); } class B : RequestResult { int add(int x) {

Re: AWS API Dlang, hmac sha256 function.

2015-10-10 Thread holo via Digitalmars-d-learn
On Friday, 9 October 2015 at 16:30:26 UTC, holo wrote: OK i find out error, in addRequestHeader i was using ":" after header name what casing problem. I removed it and now im getting "unauthorized". Here is how it looks right now: HTTP/1.1 401 Unauthorized\r\n [Expert Info

Re: AWS API Dlang, hmac sha256 function.

2015-10-11 Thread holo via Digitalmars-d-learn
After long fight with previous code i try to rewrite "one-to-one" python example from http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html (GET part) from begging to D with full success. Here is working code in clear D. Im using hmac function which is available from

Re: Class, constructor and inherance.

2015-10-11 Thread holo via Digitalmars-d-learn
By the looks, I'm guessing you do not have much experience when it comes to OOP. I think you are wanting something a bit closer to: import std.typecons : tuple, TypeTuple; interface Credential { string encode(); } class SigV4 : Credential { this() {

Re: Class, constructor and inherance.

2015-10-11 Thread holo via Digitalmars-d-learn
On Monday, 12 October 2015 at 02:30:43 UTC, Meta wrote: On Monday, 12 October 2015 at 02:14:35 UTC, holo wrote: class credential { auto accessKey = environment.get["AWS_ACCESS_KEY"]; auto secretKey = environment.get["AWS_SECRET_KEY"]; } class sigv4 : credential {

Class, constructor and inherance.

2015-10-11 Thread holo via Digitalmars-d-learn
Hello I'm trying to write my first class. I want to use it as module and build anothers on top of it. I read that default functions attributes are not inherited. Is it that same for constructor? This is how my class (not finished) is looking right now: class credential { auto

Re: Class, constructor and inherance.

2015-10-11 Thread holo via Digitalmars-d-learn
On Monday, 12 October 2015 at 03:29:12 UTC, Rikki Cattermole wrote: On 12/10/15 4:13 PM, holo wrote: By the looks, I'm guessing you do not have much experience when it comes to OOP. I think you are wanting something a bit closer to: import std.typecons : tuple, TypeTuple; interface

Re: AWS API Dlang, hmac sha256 function.

2015-10-12 Thread holo via Digitalmars-d-learn
Thank you for info, i changed my code to use that build in template and changed "cast(ubyte[]" to "xxx.representation" and it is still working: #!/usr/bin/rdmd -L-lcurl module sigawsv4; import std.stdio, std.process; import std.digest.sha, std.digest.hmac; import std.string; import

Re: Class, constructor and inherance.

2015-10-12 Thread holo via Digitalmars-d-learn
@Rikki: If you didn't need to make it easily changeable I would say not even bother with OOP at all. Basically that what i had was enough for me and on top of that i could build my app. It need to just periodically check for new instances and if they are started or stopped and count "up and

Re: AWS API Dlang, hmac sha256 function.

2015-10-05 Thread holo via Digitalmars-d-learn
On Saturday, 3 October 2015 at 23:58:39 UTC, Rikki Cattermole wrote: On 04/10/15 2:31 AM, holo wrote: On Saturday, 3 October 2015 at 12:50:58 UTC, Rikki Cattermole wrote: On 04/10/15 1:49 AM, holo wrote: On Saturday, 3 October 2015 at 12:22:11 UTC, Rikki Cattermole wrote: On 04/10/15 1:09

Re: AWS API Dlang, hmac sha256 function.

2015-10-06 Thread holo via Digitalmars-d-learn
Congrats on getting it working! @Rikki Thanks :) I was trying to write my own lib from beginning based on examples but after some time i resign from that idea (will back to it when i will have some more experience) and right now im trying to customize that one from link which yawniek paste:

Re: AWS API Dlang, hmac sha256 function.

2015-10-08 Thread holo via Digitalmars-d-learn
I was fighting with it a little bit and after all i just leave original function which was in code, removed dependencies from vibe.d and finally tried to contact api. Here is my present code: #!/usr/bin/rdmd -L-lcurl import std.stdio; import std.string; import std.file; import std.datetime;

Re: AWS API Dlang, hmac sha256 function.

2015-10-09 Thread holo via Digitalmars-d-learn
OK i find out error, in addRequestHeader i was using ":" after header name what casing problem. I removed it and now im getting "unauthorized". Here is how it looks right now: HTTP/1.1 401 Unauthorized\r\n [Expert Info (Chat/Sequence): HTTP/1.1 401 Unauthorized\r\n] Request

Re: AWS API Dlang, hmac sha256 function.

2015-10-09 Thread holo via Digitalmars-d-learn
I correct typo (thats whats happening when you trying to solve problem after night at 6:00 AM ).But still have same error. When use curl with same generated creditentials im getting "400". What is strange when im using same generated headers and signature with command line curl im getting

Re: Class, constructor and inherance.

2015-10-12 Thread holo via Digitalmars-d-learn
On Tuesday, 13 October 2015 at 02:03:46 UTC, Rikki Cattermole wrote: On 13/10/15 5:56 AM, holo wrote: @Rikki: If you didn't need to make it easily changeable I would say not even bother with OOP at all. Basically that what i had was enough for me and on top of that i could build my app.

Re: AWS API Dlang, hmac sha256 function.

2015-10-03 Thread holo via Digitalmars-d-learn
On Saturday, 3 October 2015 at 12:22:11 UTC, Rikki Cattermole wrote: On 04/10/15 1:09 AM, holo wrote: On Saturday, 3 October 2015 at 05:02:58 UTC, Rikki Cattermole wrote: On 03/10/15 6:01 PM, Rikki Cattermole wrote: On 03/10/15 4:54 PM, holo wrote: [...] By the looks of that error message

Re: AWS API Dlang, hmac sha256 function.

2015-10-03 Thread holo via Digitalmars-d-learn
On Saturday, 3 October 2015 at 12:50:58 UTC, Rikki Cattermole wrote: On 04/10/15 1:49 AM, holo wrote: On Saturday, 3 October 2015 at 12:22:11 UTC, Rikki Cattermole wrote: On 04/10/15 1:09 AM, holo wrote: [...] By the looks of things the problem is with SHA256, I'm guessing it doesn't have

Re: AWS API Dlang, hmac sha256 function.

2015-10-03 Thread holo via Digitalmars-d-learn
On Saturday, 3 October 2015 at 05:02:58 UTC, Rikki Cattermole wrote: On 03/10/15 6:01 PM, Rikki Cattermole wrote: On 03/10/15 4:54 PM, holo wrote: On Saturday, 3 October 2015 at 03:15:21 UTC, Rikki Cattermole wrote: You could implement it yourself, (it looks pretty easy). Or go the route of

AWS API Dlang, hmac sha256 function.

2015-10-02 Thread holo via Digitalmars-d-learn
Hello I'm trying to contact AWS API with D according to documentation: http://docs.aws.amazon.com/general/latest/gr/sigv4_signing.html there is written example in python which i want to rewrite to D: http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html I want to

Re: AWS API Dlang, hmac sha256 function.

2015-10-02 Thread holo via Digitalmars-d-learn
On Saturday, 3 October 2015 at 03:15:21 UTC, Rikki Cattermole wrote: You could implement it yourself, (it looks pretty easy). Or go the route of Botan: https://github.com/etcimon/botan/blob/3bdc835d5b9bad7523deaa86fe98b1fbb2f09d6b/source/botan/mac/hmac.d Thank you for answer. I used dub to

Re: Client socket sending data only one time.

2015-09-27 Thread holo via Digitalmars-d-learn
On Friday, 25 September 2015 at 04:38:06 UTC, tcak wrote: On Thursday, 24 September 2015 at 14:20:39 UTC, holo wrote: Hello I'm trying to connect to server and send data, with such simple client: #!/usr/bin/rdmd import std.stdio; import std.socket; import std.socketstream; import

Server side command execution.

2015-09-27 Thread holo via Digitalmars-d-learn
Hello Im trying to execute commands on server side. Here is my server based on other example from forum: #!/usr/bin/rdmd import std.stdio; import std.socket; import std.algorithm; import std.conv; void main() { Socket server = new TcpSocket();

Re: Server side command execution.

2015-09-28 Thread holo via Digitalmars-d-learn
On Monday, 28 September 2015 at 10:52:07 UTC, anonymous wrote: On Monday 28 September 2015 12:40, anonymous wrote: The client probably sends a newline; i.e. buffer[0 .. received] is "exit\n". Or more likely it's "exit\r\n". I changed condition to: if(to!string(buffer[0..received]) ==

Re: Server side command execution.

2015-09-28 Thread holo via Digitalmars-d-learn
On Monday, 28 September 2015 at 04:55:30 UTC, tcak wrote: On Sunday, 27 September 2015 at 23:56:10 UTC, holo wrote: Hello Im trying to execute commands on server side. Here is my server based on other example from forum: [...] You are comparing whole buffer to "exit" I changed my

Re: Server side command execution.

2015-09-28 Thread holo via Digitalmars-d-learn
On Monday, 28 September 2015 at 13:01:25 UTC, Adam D. Ruppe wrote: On Monday, 28 September 2015 at 11:44:32 UTC, holo wrote: if(to!string(buffer[0..received]) == "exit\n") You shouldn't need that to!string by the way. I believe that will work just comparing the buffer directly. Converting

Re: AWS API Dlang, hmac sha256 function.

2015-10-05 Thread holo via Digitalmars-d-learn
On Monday, 5 October 2015 at 21:00:38 UTC, Vladimir Panteleev wrote: On Monday, 5 October 2015 at 19:43:39 UTC, holo wrote: @Vladimir where can i check or do you know when next version of phobos will be available? You can use Digger to get the latest version of D:

Client socket sending data only one time.

2015-09-24 Thread holo via Digitalmars-d-learn
Hello I'm trying to connect to server and send data, with such simple client: #!/usr/bin/rdmd import std.stdio; import std.socket; import std.socketstream; import std.process; import std.conv; import core.time; void main() { char[1024] buffer = 0; Socket client = new

Re: Counting time difference.

2016-02-04 Thread holo via Digitalmars-d-learn
On Wednesday, 3 February 2016 at 22:45:03 UTC, sigod wrote: On Wednesday, 3 February 2016 at 22:27:07 UTC, holo wrote: When i start same program on server in different timezone difference is much higher (more than hour). Why it is happening? Timezones shouldnt have influence on such equation.

Counting time difference.

2016-02-03 Thread holo via Digitalmars-d-learn
Hello I'm trying to count time difference to count time for how long instance is running. Here is how am i doing it: import std.stdio, sigv4, kxml.xml, awsxml; import std.datetime; import std.string; void main() { SigV4 req = new SigV4; IfResult result = req.go; AwsXml

VibeD - takeing out value from json

2017-07-25 Thread holo via Digitalmars-d-learn
Hello I wrote such code to test restAPI client: /// //app.d /// import vibe.d; import sites.frontpage; import msfrontpage; shared static this() { // the router will match incoming HTTP requests to the proper routes auto router = new URLRouter; // registers each

Re: VibeD - takeing out value from json

2017-07-25 Thread holo via Digitalmars-d-learn
There was need to change one line from: auto header = result["heading"].to!string; to: auto header = result[0]["heading"].to!string;

Re: VibeD - undefinded identifier

2017-07-23 Thread holo via Digitalmars-d-learn
On Sunday, 23 July 2017 at 17:16:44 UTC, Seb wrote: On Sunday, 23 July 2017 at 16:37:19 UTC, holo wrote: On Sunday, 23 July 2017 at 16:27:40 UTC, Mike Parker wrote: On Sunday, 23 July 2017 at 15:23:25 UTC, holo wrote: this(auto tmp) You need to specify a type here instead of using auto.

VibeD - undefinded identifier

2017-07-23 Thread holo via Digitalmars-d-learn
Hello Im trying to create REST api for my simple web page. My code is looking like below: module service.frontpage; import vibe.d; @path("/api") interface IFrontPageAPI { Json getHome(); } class FrontPageAPI : IFrontPageAPI { this(auto tmp) { auto collect = tmp; } Json

Re: VibeD - undefinded identifier

2017-07-23 Thread holo via Digitalmars-d-learn
On Sunday, 23 July 2017 at 15:43:31 UTC, Seb wrote: On Sunday, 23 July 2017 at 15:23:25 UTC, holo wrote: Hello Im trying to create REST api for my simple web page. My code is looking like below: module service.frontpage; import vibe.d; @path("/api") interface IFrontPageAPI { Json

Re: VibeD - undefinded identifier

2017-07-23 Thread holo via Digitalmars-d-learn
On Sunday, 23 July 2017 at 16:27:40 UTC, Mike Parker wrote: On Sunday, 23 July 2017 at 15:23:25 UTC, holo wrote: this(auto tmp) You need to specify a type here instead of using auto. Thanks for reply i fix it. But right now im getting:

VibeD - RestInterfaceClient - non-constant expression

2017-07-24 Thread holo via Digitalmars-d-learn
Hello I'm trying to move forward with my code from here: https://forum.dlang.org/post/yftgpzlotuqzechcn...@forum.dlang.org I create my client app and trying to use RestInterfaceClient to connect to my api. Here is my present code for client: module sites.frontpage; import vibe.d; import

Re: VibeD - REST API and vibed.web.auth framework

2017-08-07 Thread holo via Digitalmars-d-learn
Thank you for explanation. It fix my problem with compilation. I was using https://github.com/rejectedsoftware/vibe.d/blob/master/examples/web-auth/source/app.d as example and there is @safe function. I try to compile it with newest (beta) version of vibe.d and it compiled too (so i suspect in

VibeD - REST API and vibed.web.auth framework

2017-08-06 Thread holo via Digitalmars-d-learn
Hello I'm trying to use auth framework with REST api ( http://vibed.org/api/vibe.web.auth/ ). Is it possible to use it with registerRestInterface? According to description under: http://vibed.org/api/vibe.web.auth/requiresAuth it should be available on both Web and REST. Here is my