Create bitcoin genesis block in d language

2018-04-07 Thread aerto via Digitalmars-d-announce
was playing around with d, i write a pure implementation of 
bitcoin genesis block creation in dlang 
https://github.com/cvsae/genesisd


c2 classes

2018-04-06 Thread aerto via Digitalmars-d-learn

its possible to make this work ??

import std.stdio;


class UUsers
{
public:
int age;
}


class users
{
public:
int[int] uid;

}


void main() {

users newuser = new users();
newuser.uid[0].age = 23;
writeln(newuser.uid[0].age);

}





Re: [OT] Re: merkle reverse

2018-04-05 Thread aerto via Digitalmars-d-learn

On Thursday, 5 April 2018 at 14:58:21 UTC, Andy Smith wrote:

On Thursday, 5 April 2018 at 08:12:38 UTC, aerto wrote:
This is the bitcoin genesis block merkle root 
4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b how i can get it at this format 3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a ??


i try it using

string merkle = 
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";


writeln(merkle.retro.text); and it gives me

b33adedfa7b7212ba77cc2e37667f816f78cb13c88a81523a3f98baab4e1e5a4


Yeah. Angela did some messing around with Shadow Volume 
algorithms before she got into politics...


:-)

Cheers,

A.


Is not merkel is merkle, :P




merkle reverse

2018-04-05 Thread aerto via Digitalmars-d-learn
This is the bitcoin genesis block merkle root 
4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b 
how i can get it at this format 
3ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a 
??


i try it using

string merkle = 
"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b";


writeln(merkle.retro.text); and it gives me

b33adedfa7b7212ba77cc2e37667f816f78cb13c88a81523a3f98baab4e1e5a4


string to hex convert

2018-03-29 Thread aerto via Digitalmars-d-learn

how i can convert Hello world! to hex 48656c6c6f20776f726c6421 ??






Re: dddb lightweight and simple key-value database

2018-03-25 Thread aerto via Digitalmars-d-announce

On Friday, 23 March 2018 at 05:19:16 UTC, Fra Mecca wrote:

On Thursday, 22 March 2018 at 15:34:28 UTC, aerto wrote:
I just start yesterday with d, I write dddb a lightweight and 
simple key-value database for dlang build on top of std.json 
source and usage  https://github.com/cvsae/dddb I'm waiting 
your comments


Hi, well done!
Your code is very concise, you could expand your database by 
adding tests and unit tests, that are a very important part of 
programming projects and widely supported in D.


To get an example of possible test you can check this: 
https://github.com/damphat/kv-bash


You can read about unittests in the D-Gems section 
https://tour.dlang.org/tour/en/gems/unittesting and the D wiki 
https://wiki.dlang.org/Unittest and also an article by Funkwerk 
https://dlang.org/blog/2017/10/20/unit-testing-in-action/


Also, it could be important to take care of error management in 
your program. What happens if the database stores an invalid 
json? What happens if I retrieve a key that is not in the 
database?
You can read more about error handling and exceptions and scope 
guards here: https://tour.dlang.org/tour/en/basics/exceptions


These are points that I hope can give you suggestion on how to 
further improve your code and abilities and hopefully continue 
learning D.


Thank you very much, i did some updates


dddb lightweight and simple key-value database

2018-03-22 Thread aerto via Digitalmars-d-announce
I just start yesterday with d, I write dddb a lightweight and 
simple key-value database for dlang build on top of std.json 
source and usage  https://github.com/cvsae/dddb I'm waiting your 
comments


Re: pow

2018-03-21 Thread aerto via Digitalmars-d

On Wednesday, 21 March 2018 at 16:00:56 UTC, Adam D. Ruppe wrote:

On Wednesday, 21 March 2018 at 15:56:00 UTC, aerto wrote:
why pow(256, 27) gives 0, instead of 
105312291668557186697918027683670432318895095400549111254310977536L


that result is simply too big to fit in the result. Try using a 
bigint instead:


import std.bigint, std.stdio;

void main() {
BigInt i = 256;
i ^^= 27;
writeln(i);
}


thanks, a last question in a diffrent function i use 
writeln(105312291668557186697918027683670432318895095400549111254310977536L); and i get Error: integer overflow any solution >?






pow

2018-03-21 Thread aerto via Digitalmars-d
why pow(256, 27) gives 0, instead of 
105312291668557186697918027683670432318895095400549111254310977536L


load data from txt file

2018-01-02 Thread aerto via Digitalmars-d

Hello and happy new year im new in d so i have a question

i have into a txt file named users.txt the bellow

["admin":"123456789"]
["test":"test345"]


im my app

string[string] data;

so i need to load users.txt content into data in order to be able 
to run



writeln(data["admin"]); // i want this to print 123456789
writeln(data["test"]); // i want this to print test345