Re: [go-nuts] How to convert time interval in days to human readable form?

2020-01-24 Thread Christian Mauduit
If the only input you have is a number of days, as opposed to a start
date and a finish date, it is not possible to convert it in years/months
as the length of the years, as well as the length of the years, vary
over time. Years can range from 365 to 366 days. Months can range from
28 to 31 days.

As a side note, I am not sure this is strictly Go related.

Have a nice day,

Christian.

On 24/01/2020 18:06, Constantine Vassilev wrote:
> I have the following task:
> 
> 1) a number representing days.
> 2) how to convert it to human readable form?
> 
> Like this:
> 11 years 3 months 5 days
> 
> The actual calculations are:
> 
> 4095 days = 136.5 months = 11.375 years
> 
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to golang-nuts+unsubscr...@googlegroups.com
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/golang-nuts/4534a893-73f1-495a-be64-1992a3b4819f%40googlegroups.com
> <https://groups.google.com/d/msgid/golang-nuts/4534a893-73f1-495a-be64-1992a3b4819f%40googlegroups.com?utm_medium=email_source=footer>.

-- 
Christian Mauduit__/\__  ___
uf...@ufoot.org  \~ ~ / (`_ \   ___
https://ufoot.org/_o _\\ \_/ _ \_
int q = (2 * b) || !(2 * b);   \/   \___/ \__)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/6553b5be-8530-f9a3-7a62-901d98de297c%40ufoot.org.


Re: [go-nuts] Is there some kind of a MaxHeapAlarm implementation?

2020-01-20 Thread Christian Mauduit
  }
}

--
You received this message because you are subscribed to the Google 
Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send 
an email to golang-nuts+unsubscr...@googlegroups.com 
<mailto:golang-nuts+unsubscr...@googlegroups.com>.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3408da0e-f420-4b3d-98f0-d0a06e95d398%40googlegroups.com 
<https://groups.google.com/d/msgid/golang-nuts/3408da0e-f420-4b3d-98f0-d0a06e95d398%40googlegroups.com?utm_medium=email_source=footer>.


--
Christian Mauduit__/\__  ___
uf...@ufoot.org  \~ ~ / (`_ \   ___
https://ufoot.org/_o _\\ \_/ _ \_
int q = (2 * b) || !(2 * b);   \/   \___/ \__)

--
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/3ddf2728-ec41-303c-12e2-bf378ba67cc7%40ufoot.org.


Re: [go-nuts] Panicking in public API ?

2020-01-07 Thread Christian Mauduit
I'd suggest you expose both kind of APIs as in:

* https://golang.org/pkg/regexp/#Compile
* https://golang.org/pkg/regexp/#MustCompile

Implementing the `Must` flavor is trivial, just call the standard func
and panic() if you get an error. As a side effect you'll get a unique
point where to panic(), and callers will recognize it's likely yo
panic() because the function has "Must" in its name.

If in doubt, implement only the func that returns the error, the other
is just syntaxic sugar IMHO. Example:

https://golang.org/src/regexp/regexp.go?s=10768:10804#L298

panics() have been, in my Golang experience, a pain to deal with. Most
of the time they are just below a "TODO refactor that sh*t" comment, or
they would deserve that comment anyway. Proper error handling takes
time, but it's an investment that pays of.

My 2c.

Christian.

Le 07/01/2020 à 8:10 AM, Tay a écrit :
> Hi,
> 
> Just a quick question. I know it's well accepted that panics leaking to
> the public API of a library is generally a no-go.
> 
> Yet, are there any exception to the rule?
> 
> For instance, I have a library that instantiates some database prepared
> statements (so, the majority of the elements are instantiated and used
> in the main function). I would like to panic instead of returning an
> error because, if db.Prepare(q) returns an error, there is no point in
> continuing, the error is barely recoverable. Besides, it will allow for
> a better looking API so to speak.
> 
> Any comments?
-- 
Christian Mauduit__/\__  ___
uf...@ufoot.org  \~ ~ / (`_ \   ___
https://ufoot.org/_o _\\ \_/ _ \_
int q = (2 * b) || !(2 * b);   \/   \___/ \__)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/e7cd8115-bdb3-9edb-006b-1b5100e4cd7e%40ufoot.org.


Re: [go-nuts] [?] emulating an opengl shader in cpu bound functions

2016-06-21 Thread Christian Mauduit
Hi,

Using OpenGL to draw something that will end up on paper might prove
somewhat complicated. As for "translating" a shader to something cpu
bound, since a shader is more or less a program in some language that
"has some remote parentness with C", you could probably do it. But the
most pragmatic way, IMHO, is to understand what the program does and
rewrite it. If you really want to leverage OpenGL's power, I know it
allows you to render "in memory" so you could draw things on a virtual
screen, grab the output, and you're set. To some extent, recent OpenGL
with shaders is more or less a generic way to harness the power of
massive parallel, dedicated hardware, and it's very versatile. But
complex as well.

If you are not a graphics guru, I'd advice you to use a plain simple
native Go library, there are several candidates, one is :

https://github.com/llgcode/draw2d/

Have a nice day,

Christian.

On 06/20/2016 05:02 PM, bluebl...@gmail.com wrote:
> <https://lh3.googleusercontent.com/-bPOQJTHF8Js/V2gEJqUg5jI/ACI/lg6cWG0cJqo0tFl4wsuDYF2w4kycTbRPACLcB/s1600/blank.png>
> 
> 
> I am attempting to generate a random starfield, in go. This is something
> that will need to printed on actual paper, but that is another issue and
> I only mention it to give some context for what I am doing here: Using
> go to create graphics to pair with something I'm already doing in go
> (I've been through several iterations of trying to use the go parts I
> have with numerous variations of tex/latex templates using asymptote,
> and I reached a point of frustration where I figured why not just do it
> all in go, as it seems less a problem than I originally thought -- but
> opens a new set of problems to solve, one of the biggest is that I know
> nothing at all about graphics, let alone how to apply graphics in go).
> 
> Cosmic1 from: 
> https://gist.github.com/thrisp/1ed1785ac6a902585595fb8cb52f0a16,
> generates the above it is the first thing that even roughly approximates
> what I want to do.
> 
> Any thoughts, or help cleaning that up. Maybe tell me why exactly I
> can't directly translate an opengl shader to something cpu bound(which I
> suspect is a thing, I may need to do more that I can't see right now).
> 
> -- 
> You received this message because you are subscribed to the Google
> Groups "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to golang-nuts+unsubscr...@googlegroups.com
> <mailto:golang-nuts+unsubscr...@googlegroups.com>.
> For more options, visit https://groups.google.com/d/optout.

-- 
Christian Mauduit
uf...@ufoot.org
http://www.ufoot.org
int q = (2 * b) || !(2 * b);

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.