Giter Site home page Giter Site logo

gox's People

Contributors

devhindo avatar icza avatar ssgelm avatar yunginnanet avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

gox's Issues

error with opening link in windows using `func OpenDefault(fileOrURL string) error`

func OpenDefault(fileOrURL string) error cuts the link on & sign on windows with chrome browser

the original link: https://twitter.com/i/oauth2/authorize?response_type=code&client_id=emJHZMUdHM9QRlRIdk45QjY6MTpjaQ&redirect_uri=https://blush.app/api/auth&scope=tweet.read%20tweet.write%20users.read%20users.read%20follows.read%20follows.write%20offline.access&state=op-oLJWRfa8d84GkoLjE_euBQB_naZfisK3JSjcuWHtMk9O_IdSBhr2ZVQkfmXsAvO_HDIIXCTl3kHYGwpDbTGZ33u3t2OG6Zlkb-kh0ITcZh_nsC7IecKPWzl0Rf1dKwh5LmtMqhp5xkZCPAMMPpgHSDUzADVO2oGA==&code_challenge=gkzQm0D3IAGMY3CHDfafxGYnqofW4pfNB6yah0&code_challenge_method=S256
the opened link:   https://twitter.com/i/oauth2/authorize?response_type=code

p.s. It works fine on linux

Unexpected mathx.Round() result when rounding to 2 decimal places

I've ran into some difficulties when tried to find a way to round float64 values to 2 decimal places. Maybe smn can explain am I wrong or suggest a solution, if exists.
P.S. I know about IEEE-754 floating point standard

I've found 2 values that rounds in a way I don't expect - 1.275 and 4.935.

1.275 is expected to become 1.28 (but I get 1.27)
4.935 is expected to become 4.94 (but I get 4.93)

Example code (Go version 1.19):

package main

import (
	"fmt"

	"github.com/icza/gox/mathx"
)

func main() {
	print(2.345, 0.01, 2.35) // ok
	print(1.275, 0.01, 1.28) // fail #1
	print(4.935, 0.01, 4.94) // fail #2
}

func print(f, unit, exp float64) {
	rounded := mathx.Round(f, unit)
	fmt.Printf("input: %.3f | got: %.3f | expected: %.3f\n", f, rounded, exp)
}

Output:

input: 2.345 | got: 2.350 | expected: 2.350
input: 1.275 | got: 1.270 | expected: 1.280
input: 4.935 | got: 4.930 | expected: 4.940

Are my expectations wrong?

Managed to workaround it in the next code, but I'm not sure if it will fix everything and not break smth else:

func round2(f float64) float64 {
	// return math.Floor(f*100+0.5) / 100.0 // same rounding issue as mathx.Round(f, 0.01)
	// return math.Floor(f*100+0.5+1e-14) / 100.0 // fixes 1.275, but not 4.935
	return math.Floor(f*100+0.5+1e-13) / 100.0 // 1e-13 helps with both 1.275 and 4.935
}
// problem is when I multiply by 100 and then rounding breaks
// 1) 1.275 * 100 = 127.49999999999999 (instead of 127.5)
// 2) 4.935 * 100 = 493.49999999999994

An Apache 2.0 licence but no copyright information

According to the Apache 2.0 license:

"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
APPENDIX: How to apply the Apache License to your work.

To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!)  The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.

   Copyright {yyyy} {name of copyright owner}

I want to attribute the work in this repo, but I could not find any such copyright notices in any of the source files. To me it is unclear how the Apache 2.0 License works without copyright notice. Is this something you could fix @icza?

Extra information
The "Redistribution" of the Apache 2.0 Licence applies to the "Work", which (as stated above) is indicated by a copyright notice.

Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:      

format does not work on 28th of February

I have a test where I set exact expiry date and then test if the format is printed correctly. My tests started failing today (28th of February), because I am missing 2 days. This is output from my test:

expected: "3 years 2 months 7 days 5 hours 25 minutes"
actual  : "3 years 2 months 5 days 5 hours 25 minutes"

All I am doing in the test is creating a future time:

func getTime(years, months, days, hours, minutes int) time.Time {
	return time.Now().AddDate(years, months, days).
		Add(time.Hour*time.Duration(hours) + time.Minute*time.Duration(minutes))
}

And then comparing time that is formatted by (where t is the time generated by getTime function):

year, month, day, hour, minute, _ := timex.Diff(time.Now(), t)

Tests fail to run on 32-bit architectures

Hi,

In building this for Debian I discovered that the math tests fail to run on 32-bit architectures, specifically

{"minint32", math.MinInt32, -math.MinInt32},

Because Int is a 32-bit integer on 32-bit architectures, -math.MinInt32 is one too big and causes an overflow. I'm happy to submit a PR to fix this, but I'm not sure how you'd prefer this be fixed. The easiest would be to either remove the test or to add 1 to MinInt32. What would you prefer be done to fix this?

Licensing and Attribution

gox does not contain a NOTICE file or any other obvious way of handling attribution to comply with the Apache 2.0 license.

Would you consider creating a NOTICE file or stating in the README how you would prefer attribution be handled?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.