Re: How to add time to Clock.currTime

2013-10-07 Thread JohnnyK
On Saturday, 5 October 2013 at 02:42:49 UTC, Jonathan M Davis 
wrote:

On Saturday, October 05, 2013 03:31:33 JohnnyK wrote:
Wow I appreciate the quick response. Ok I have seen this 
before.

What is the dur? Where is dur defined? Also I am confused how
300.seconds would work. How can a literal number have 
properties?


dur is in core.time as are the aliases for each of the units:

http://dlang.org/phobos/core_time.html#dur

300.seconds works thanks to UFCS (Universal Function Call 
Syntax). Any time

that the compiler sees

x.foo(args);

and foo is not a member function of x, it converts it to

foo(x, args);

So, if there's a free function with that name which will work 
with those
arguments, then it will be called (otherwise, you'll get an 
error, because
there is no matching function). The parens can be dropped on 
300.seconds,
because the parens are optional on function calls that take no 
arguments.
seconds is not actually a property function (it's an alias for 
dur!"seconds,
which is not a property function either), but the fact that the 
parens are
optional makes it so that you can use it with the same syntax 
that would be

used for a getter property.

If you want an overview of std.datetime and the time stuff in 
Phobos, I suggest

that you read

http://dlang.org/intro-to-datetime.html

- Jonathan M Davis


I appreciate everyone's responses and yes Jonathan that article 
did help.  I know I looked under the article section but I must 
have overlooked this article.


Re: How to add time to Clock.currTime

2013-10-04 Thread JohnnyK

On Friday, 4 October 2013 at 21:54:19 UTC, Brad Anderson wrote:

On Friday, 4 October 2013 at 21:50:31 UTC, Brad Anderson wrote:

On Friday, 4 October 2013 at 21:46:43 UTC, JohnnyK wrote:

Hi All,
I did search but I cannot find it anywhere.  All I want to do 
is add 300 seconds to the output of Clock.currTime.  So 
basically if Clock.currTime equals 2013-Oct-04 
17:19:31.3338333 then I want to subtract 300 seconds from 
that to get the time that it was 300 seconds ago.  In other 
languages I would convert the time value to seconds and 
subtract the 300 seconds then convert it back to what ever 
time value it was before. I don't know how to convert 300 
seconds to hnsecs and I have never actually heard of hnsecs 
before.  Anyway if someone could help I would appreciate it.


auto t = Clock.currTime;
t -= 300.seconds;
t += 300.seconds;


And just a little bit more info, another way to write this is:

auto t = Clock.currTime;
t -= seconds(300);
t += seconds(300);

The first way I wrote is just the UFCS version of that.

You could also do:

auto t = Clock.currTime;
t -= dur!"seconds"(300);
t += dur!"seconds"(300);

seconds() is just an alias for the dur template with the 
"seconds" template argument.


Wow I appreciate the quick response.  Ok I have seen this before. 
 What is the dur?  Where is dur defined?  Also I am confused how 
300.seconds would work.  How can a literal number have properties?


How to add time to Clock.currTime

2013-10-04 Thread JohnnyK

Hi All,
  I did search but I cannot find it anywhere.  All I want to do 
is add 300 seconds to the output of Clock.currTime.  So basically 
if Clock.currTime equals 2013-Oct-04 17:19:31.3338333 then I want 
to subtract 300 seconds from that to get the time that it was 300 
seconds ago.  In other languages I would convert the time value 
to seconds and subtract the 300 seconds then convert it back to 
what ever time value it was before. I don't know how to convert 
300 seconds to hnsecs and I have never actually heard of hnsecs 
before.  Anyway if someone could help I would appreciate it.


request for a RSS feed of the D Forum

2013-07-16 Thread JohnnyK
I could not find any posts on this and have not found a link on 
the site about this either.  It would be nice if there was a RSS 
feed for the forum at least for the announce forum.  It is very 
difficult to monitor changes and updates with so much activity 
just through the forum.  Sorry if this is the wrong place to post 
this but I did not see a forum for Forum suggestions or web site 
suggestions.


Re: pointers, assignments, Garbage Collection Oh My?

2013-07-10 Thread JohnnyK

On Wednesday, 10 July 2013 at 18:45:56 UTC, H. S. Teoh wrote:

On Wed, Jul 10, 2013 at 08:38:40PM +0200, JohnnyK wrote:
[...]

Reminds me of how Delphi (aka Pascal) strings are work.  Thanks
everyone this answers some of my questions.  Now what about 
when the
return type of a function is a string?  Is D returning the 
pointer

to the string structure or is it returning the structure?


D structs are always passed by value, so it's the 
length+pointer pair
that's being returned. There's no extra indirection involved 
here. What

it points to stays where it is on the GC heap.

So for example:

int[] data = [1,2,3];

int[] f() {
return data;
}

void main() {
auto arr = f(); // returns copy of data's ptr+length
arr.length--;   // modifies this copy
assert(arr == [1,2]);
assert(data == [1,2,3]); // data itself hasn't changed
}

Does this help?



I understand thanks for the information.


Re: pointers, assignments, Garbage Collection Oh My?

2013-07-10 Thread JohnnyK

On Wednesday, 10 July 2013 at 18:22:24 UTC, Ali Çehreli wrote:

On 07/10/2013 11:10 AM, Sean Kelly wrote:

> On Jul 10, 2013, at 10:45 AM, Namespace
 wrote:
>
>>> A string in D, and all arrays, is a struct looking like
this:
>>>
>>> struct Array (T)
>>> {
>>> T* ptr;
>>> size_t length;
>>> }
>>
>> I always thought it looks like this:
>>
>> struct Array(T) {
>> T* ptr;
>> size_t length, capacity;
>> }
>
> Sadly, no.  The only way to determine the capacity of an
array is to query the GC.
>

And to be pedantic, length comes first:

struct Array (T)
{
size_t length;
T* ptr;
}

Which is actually property-like because assigning to length 
does pretty complex stuff. So the member cannot be named as 
'length':


struct Array (T)
{
size_t length_;
T* ptr;
}

Anyway... :)

Ali


Reminds me of how Delphi (aka Pascal) strings are work.  Thanks 
everyone this answers some of my questions.  Now what about when 
the return type of a function is a string?  Is D returning the 
pointer to the string structure or is it returning the structure?


pointers, assignments, Garbage Collection Oh My?

2013-07-10 Thread JohnnyK
I hope you like the subject matter and I hope it is not too 
simplistic or have been answered before.
  Anyway I have a question about how the garbage collector works 
in a very specific situation.  When passing string type to a 
function in a shared library or DLL and assigning it to a 
variable of type string inside the function and returning the 
internal string.  Such as this.


export string mytest(string tstStr)
{
  string st = tstStr;
  /* abbreviated to protect the innocent but other operations
 such as concatenating and deleting may be done to st before 
the return

  */
  return st;
}

Is the string type a pointer or is it something else?  In the 
line where tstStr is assigned to st does it copy the address in 
tstStr to st or does it copy the value in tstStr?  I am just a 
bit confused about string types since I come from a C background 
and C has no type like this.  Also what is returned by this 
function?  Does this function return a pointer or the contents of 
an array?  If I do export this what does it do to the Garbage 
Collection?  Does the Garbage Collection collect tstStr or st?  
Also notice the comment in the function.




Re: GitHub behind proxy servers among other questions

2013-07-09 Thread JohnnyK

On Tuesday, 9 July 2013 at 08:55:29 UTC, monarch_dodra wrote:

On Monday, 8 July 2013 at 19:20:46 UTC, John Colvin wrote:
I don't see how it is problematic? The firewall doesn't allow 
a particular type of connection, so you cache the result 
somewhere else and then access it via something that is 
allowed.


It's the same as downloading the zip file from github, only 
you're doing the "zipping" yourself, then using scp to do the 
download instead of http.


Is it common to have ssh connections banned in the IT policy 
but *not* blocked by the firewall?


I'm just saying that maybe the firwall is blocking that 
protocol on purpose? Github can very easily be seen as "File 
Sharing" and/or "Online Storage". The sole act of 
downloading/uploading anything on there is possible violations 
of policy. You could download viruses, or be stealing your 
company's code to publish it online. Even if you *can* download 
the zip via http, it doesn't mean you are actually allowed to. 
If your company's firewall doesn't block a porn site, does that 
means its OK to surf it?


Now, most companies wouldn't really care that much about it, if 
you connect every now and then, no one will care. Worst case 
scenario, you'll get a reminder not to download/upload crap on 
internet.


But, if you start doing all this via ssh, or other alternative 
routes, then you are *activelly* bypassing protections, and in 
particular, doing something you *know* you shouldn't be doing. 
That's a more serious offense.


Now, do what you want. I'm just saying before going it and 
deploying such tools to download the files on git, please make 
sure you aren't violating your company's policies.


  I do not encourage anyone to bypass network security 
protections and I do encourage letting your conscious be your 
guide on this topic.


  The issue is that it is just more complicating than I think it 
should be to download libraries and such.  Authors of helper 
libraries and other D related code should take their queue from 
dlang.org and actually have binaries that users can download and 
just use without the need to compile before they can use the 
wares.  It is not a firewall issue or anything like that.  It was 
just GIT not supporting modern proxy authorization schemes.  
Problem resolved but it could have been avoided all together for 
those of us that are not to the point of contributing to these 
projects and are just trying to get their feet wet without 
drowning first.
On another note I was able to successfully compile the DWT lib 
and I was able to compile the snippet example programs to test 
DWT.  I did notice for those that are interested DWT exe's are 
over 2MB which is really what I was wanted to find out.  I will 
redirect DWT questions to the appropriate forum.


  The workaround for GIT via proxy is just not as pretty as I 
would have liked it.  However as I posted previously I found a 
suitable workaround for the issue.  No other discussion is needed 
for this issue.




Re: GitHub behind proxy servers among other questions

2013-07-08 Thread JohnnyK

On Monday, 8 July 2013 at 19:37:08 UTC, JohnnyK wrote:
Another thing about GitHub's Download Zip button and this process 
as a whole.  While the Download Zip button does allow you to 
download the master folders with recursive directories I do find 
it somewhat cumbersome or should I say awkward since you have to 
extract these in their correct locations upon download.  This is 
not good when you are trying to follow someones instructions on 
how to download, build, and install their wares.  I just don't 
get git?  Just compile the code and put a binary up there for 
people to use.  If I want to contribute to the code base then I 
will I guess go through all this hassle but for those of us not 
smart enough to contribute and just want to use it show me the 
binary please.  In the amount of time it is taking to get this 
stuff I could have made major strides at building my own.  Also I 
don't know what this fragmented downloading is going to do in the 
future when I want an updated version of the software.  Please 
remember many of us are simpletons and don't use all these fancy 
version control systems and just need the binary so that we can 
use it.  I guess you could say we are your customers and not your 
contributors.  Please everyone in the D community try and follow 
the KISS methodology and if you do I bet you could get many more 
users of your wares and not people banging their heads until they 
give up.  Yeah I was only 2 clicks away from giving up on this 
whole D thing thinking it was just too darned hard to make it 
worth my while.  Who knows I still may give up since I have not 
attempted to compile it yet.  I think I will wait until tomorrow 
before I try to tackle that part of the destruction's.  For now I 
think I have it downloaded.  BTW did I mention that I really hate 
git and compiling other people's code just to use an edit box and 
button on a dialog???


Re: GitHub behind proxy servers among other questions

2013-07-08 Thread JohnnyK

On Monday, 8 July 2013 at 18:34:33 UTC, Jesse Phillips wrote:

On Monday, 8 July 2013 at 16:24:53 UTC, JohnnyK wrote:

It would be nice if GitHUB would change their Downlaod Zip 
button such that it does a recursive zip to include all the 
subfolders.


Ehhh, well that is useless. Sorry I couldn't hook you up with a 
solution.


Thanks for all the input.  I found a tool called NTLMAPS at 
http://ntlmaps.sourceforge.net/ which allows one to create a pass 
through proxy which understands NTLM proxy servers and are able 
to connect and forward HTTP requests and return responses so long 
story short I can now git clone as I need to NTLMAPS config file 
is pretty easy to configure with your proxy authentication 
information.  However I did have to change the following 
named/value pairs.


from this

LM_PART:1
NT_PART:0

# Highly experimental option. See research.txt for details.
# LM - 0682
# NT - 0582
# LM + NT - 0782
NTLM_FLAGS: 0682

to this

LM_PART:1
NT_PART:1

# Highly experimental option. See research.txt for details.
# LM - 0682
# NT - 0582
# LM + NT - 0782
NTLM_FLAGS: 0782

The proxy that I am behind was not happy until I did that.  
Anyway it is working now and I hope this post serves to help 
others with the same issue.


also note that I had to use http:// in place of git:// in the git 
paths and in the case of DWT I had to go to every major folder 
and git clone them individually because for some reason git 
wanted to use git:// for subsequent requests.  It is strange that 
it did not do that for the Win-Res folder just for the others.  
So I had to do commands like the following


C:\GITClones>cd dwt

C:\GITClones\dwt>git clone --recursive 
http://github.com/d-widget-toolkit/base.g

it
Cloning into 'base'...
remote: Counting objects: 806, done.
remote: Compressing objects: 100% (326/326), done.
remote: Total 806 (delta 402), reused 803 (delta 401)
Receiving objects: 100% (806/806), 310.62 KiB | 261.00 KiB/s, 
done.

Resolving deltas: 100% (402/402), done.

C:\GITClones\dwt>git clone --recursive 
http://github.com/d-widget-toolkit/org.ec

lipse.swt.gtk.linux.x86.git
Cloning into 'org.eclipse.swt.gtk.linux.x86'...
remote: Counting objects: 1691, done.
remote: Compressing objects: 100% (634/634), done.
remote: Total 1691 (delta 951), reused 1659 (delta 944)
Receiving objects: 100% (1691/1691), 1.71 MiB | 361.00 KiB/s, 
done.

Resolving deltas: 100% (951/951), done.

C:\GITClones\dwt>git clone --recursive 
http://github.com/d-widget-toolkit/org.ec

lipse.swt.win32.win32.x86.git
Cloning into 'org.eclipse.swt.win32.win32.x86'...


The only other thing I wish git could do is compile it for me so 
that I wouldn't have too but until we have HDgit I guess I am 
stuck with all this command line busy work.  Thanks again for 
every ones time.


Re: GitHub behind proxy servers among other questions

2013-07-08 Thread JohnnyK

On Monday, 8 July 2013 at 03:35:03 UTC, Jesse Phillips wrote:

On Monday, 8 July 2013 at 02:42:50 UTC, JohnnyK wrote:

Hi all,
 I have searched everywhere over the Internet and I have yet 
to find a way to clone a project using git when my workstation 
is behind a company proxy.  Can you guys clone your projects 
to a single zip file that I can download?  This would be 
easier instead of working with some strange command-line tool 
that does not recognize modern networks.  Honestly I just need 
the DWT binary with the help files so I can use the api.  I 
have spent weeks searching for a way to download DWT to my 
windows workstation at work and have yet figured out how to 
make GIT work.


Git provides a download by zip; Right side, bottom.

This is what I found on getting Git to work with a proxy:

http://stackoverflow.com/questions/128035/how-do-i-pull-from-a-git-repository-through-an-http-proxy


I appreciate your response.  I have tried these.  I think the 
real issue is that I am not sure on the IP and port needed for 
the proxy here at work.  The company uses WPAD in the browser and 
I cannot figure out what the IP and port the browser is using to 
connect through the proxy.  If I knew that I probably could make 
it work.  It would be nice if GitHUB would change their Downlaod 
Zip button such that it does a recursive zip to include all the 
subfolders.


GitHub behind proxy servers among other questions

2013-07-07 Thread JohnnyK

Hi all,
  I have searched everywhere over the Internet and I have yet to 
find a way to clone a project using git when my workstation is 
behind a company proxy.  Can you guys clone your projects to a 
single zip file that I can download?  This would be easier 
instead of working with some strange command-line tool that does 
not recognize modern networks.  Honestly I just need the DWT 
binary with the help files so I can use the api.  I have spent 
weeks searching for a way to download DWT to my windows 
workstation at work and have yet figured out how to make GIT work.