NHacker Next
  • new
  • past
  • show
  • ask
  • show
  • jobs
  • submit
Show HN: Daylight – track sunrise / sunset times in your terminal (github.com)
oftenwrong 3 days ago [-]
I was curious how the times were obtained. It uses https://github.com/nathan-osman/go-sunrise , which links to this calculation method: https://en.wikipedia.org/wiki/Sunrise_equation#Complete_calc...
achillesheels 3 days ago [-]
Great link thanks!
ndegruchy 3 days ago [-]
Of course, you can get this information in Emacs, too. You'll need to get your lat and long, first:

    (setq calendar-latitude  12.3456
          calendar-longitude -98.7654)
Then, you can `M-x sunrise-sunset` and see the times (and total daylight hours) in the echo area.
michaelmcdonald 3 days ago [-]
Relevant XKCD: https://xkcd.com/378/
rrr_oh_man 3 days ago [-]
Great looking app!!

I immediately checked how you do location lookups:

> IP lookup is powered by https://ipinfo.io. They provide a good service so please don't spam requests.

There was a thread about them recently — the scale of their operation was very surprising.

reincoder 2 days ago [-]
Thank you very much! I appreciate talking with you in the other thread! I told the repo owner not to worry about "spamming" our service. We are happy to support as many requests as people can throw at us.

Internally, when it comes to API requests, we are doing our best to reach an "unlimited" level of API requests. On the operational side, we are just getting started. The distributed network of a thousand servers we operate only runs a handful of diagnostic tests (ping, traceroute, etc.).

We have a lot of plans, and I hope you will find us providing more fun stuff as we continue to grow!

jbreckmckye 3 days ago [-]
It _is_ possible to use native OS APIs for location lookup, but these all seem to rely on cgo. Which was a bit intimidating for a "let's learn Golang" project

(Probably not the nicest code and no doubt I've broken a lot of Go idioms, but it was a good learning exercise)

IPInfo is a good service and their developer relations were surprisingly relaxed about me (mis)using their API this way

reincoder 2 days ago [-]
"Surprisingly relaxed," you say. Let me tell you about the time our users reverse-engineered our apps, submitted 2.2 million IPs, and broke our systems for our hackathon.

https://ipinfo.io/blog/ipinfos-ip-hunt-2-2-million-ips-submi...

This is just our user base, to be honest and we like them for their mindset. We are happy to see users try our service in different ways and we learn a ton from them in that process. I certainly learned from you :)

japaget 3 days ago [-]
Windows build works fine (Windows 10 Professional x64 22H2).
jbreckmckye 3 days ago [-]
Thanks! (Don't have a Windows machine right now so that's very helpful)
voidUpdate 3 days ago [-]
Does this pull the times from an online service or are they calculated locally? I tried to read the code to work it out but I don't program in Go so I got a little lost
jbreckmckye 3 days ago [-]
It gets your latitude/longitude from an IP lookup service, then does a geometric calculation locally
jmholla 3 days ago [-]
Is there a configuration file or command line option to provide location information manually?
jbreckmckye 3 days ago [-]
Yes, you can use `--loc="12.34,56.78"` where the values are longitude and latitude.

You can also override the Timezone with `--timezone` (passing an IANA timezone e.g. America/New_York).

thenthenthen 3 days ago [-]
Cool! Can we use the sky hue as Terminal background or overal “theme”?
kseistrup 3 days ago [-]
This is nice, I like it!

Is there a way to make it use 24h time, rather than AM/PM?

kseistrup 3 days ago [-]
If I use e.g. `daylight --timezone=Europe/Copenhagen` it does actually show the 24h times, which is nice. But til still appends AM/PM, which is kind of weird. :)
jrootabega 3 days ago [-]
Is the noon color scheme supposed to look like Finn from Adventure Time?
6 days ago [-]
Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact
Rendered at 15:52:38 GMT+0000 (Coordinated Universal Time) with Vercel.