News for hackers. Stuff that matters.
Re:A command-line weather app built using Elixir by rnhmjoj on Thursday May 07, 2015 @09:04AM (#9504712)

  function weather(){curl -s "http://api.openweathermap.org/data/2.5/weather?q=$1&units=metric" | jq .main.temp | figlet -kcf big}

  $ weather london
                            __  _  _     ___   _____
                           /_ || || |   |__ \ | ____|
                            | || || |_     ) || |__
                            | ||__   _|   / / |___ \
                            | |   | | _  / /_  ___) |
                            |_|   |_|(_)|____||____/
Re:A command-line weather app built using Elixir by q3k on Thursday May 07, 2015 @10:22AM (#9505211)
But that's not web-scale and written in a functional language!
Re:A command-line weather app built using Elixir by taternuts on Thursday May 07, 2015 @01:58PM (#9506977)
Cool! for fahrenheit you can change the units to imperial

  function weather(){curl -s "http://api.openweathermap.org/data/2.5/weather?q=$1&units=imperial" | jq .main.temp | figlet -kcf big}
Re:A command-line weather app built using Elixir by gknoy on Thursday May 07, 2015 @11:55AM (#9505965)
Perhaps I'm a bash noob, but when I try to paste that in my shell, it complains about a syntax error near `{curl`. Am I doing something wrong?
Re:A command-line weather app built using Elixir by cocoflunchy on Thursday May 07, 2015 @12:00PM (#9506014)
There are spacing issues for me. Try

    function weather() { curl -s "http://api.openweathermap.org/data/2.5/weather?q=$1&units=metric" | jq .main.temp | figlet -kcf big ;}
Re:A command-line weather app built using Elixir by rnhmjoj on Thursday May 07, 2015 @12:46PM (#9506403)
I wrote this in zsh. It seems in bash you need to add a space before the bracket
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:23PM (#9506232)
May be you should post a gist. The line is getting truncated.
Re:A command-line weather app built using Elixir by rnhmjoj on Thursday May 07, 2015 @12:41PM (#9506371)
It should scroll horizontally.
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @01:02PM (#9506544)
my bad :(
Re:A command-line weather app built using Elixir by renekooi on Thursday May 07, 2015 @06:43AM (#9504113)
Another ASCII art weather (forecast) utility, but in Go: https://github.com/schachmat/wego
Re:A command-line weather app built using Elixir by iamcurious on Thursday May 07, 2015 @10:27AM (#9505246)
Unlike the main post, this is a good use of ASCII art. i.e. to show a drawing/symbol not to make numbers more difficult to parse...
Re:A command-line weather app built using Elixir by flaie on Thursday May 07, 2015 @07:15AM (#9504228)
This is much much better. Closer to "beautiful" than the one featured here.
Re:A command-line weather app built using Elixir by lectrick on Thursday May 07, 2015 @12:20PM (#9506201)
Yeah, it's beautiful if

1) you think mutable variables are beautiful

2) you think stuffing everything into one file is beautiful

3) you think defining functions at the root namespace is beautiful

4) you think consecutive repeated property accesses stuffed into a consecutively repeating boolean check like this are beautiful: if h.Time == "0" || h.Time == "100" || h.Time == "200" || h.Time == "300" || h.Time == "400" || h.Time == "500" || h.Time == "600" || h.Time == "700" || h.Time == "1400" || h.Time == "1500" || h.Time == "1600" || h.Time == "2300"

5) if you think embedding ANSI color codes across all strings instead of centralizing all that ugliness somewhere is beautiful

6) if you think not separating your command-line-handling code from your problem-modeling code is beautiful (see: Hexagonal Architecture http://alistair.cockburn.us/Hexagonal+architecture)

7) If you think having no fucking test suite to speak of, given all that mangled mutating code is beautiful (to me this is the MOST egregious non-beautiful thing in the entire "project")

Then, yes. WeGo is beautiful.

Frankly I'm shocked that what people call "beautiful" can differ that fucking much.

Re:A command-line weather app built using Elixir by commentzorro on Thursday May 07, 2015 @03:18PM (#9507565)
I think the parent was referring to the console display output rather than the code itself.
Re:A command-line weather app built using Elixir by lectrick on Thursday May 07, 2015 @10:02PM (#9509628)
lol. then I guess I will step off my pedestal and agree. I mean... I think Figlet does a better job than all of these, but anyway
Re:A command-line weather app built using Elixir by djm_ on Thursday May 07, 2015 @07:33AM (#9504296)
Can anyone explain why a dependency of this app is a "working Go environment"? I thought one of golang's selling points was the fact that it created a simple binary.

As far as I can tell, the Go environment is simply being used as a cheap installer, is that correct?

Re:A command-line weather app built using Elixir by fit2rule on Thursday May 07, 2015 @07:45AM (#9504348)
In my opinion its more like: Go comes with a package-management/install system onboard, and for every 'go install', there's a full copy of working sources which someone, some day, might consider reading and contributing to ..

So I think, at least as a go newbie, that its quite handy that pretty much every tool I might be interested in - because it was written in Go - comes with full sources onboard as a basic, starting-gate, expectation. At least, I am quite happy to be learning Go this way ..

Re:A command-line weather app built using Elixir by laumars on Thursday May 07, 2015 @07:41AM (#9504332)
Because he's sharing the source code rather than a compiled binary. It's no different to having make + gcc listed as a dependency for C++ code.
Re:A command-line weather app built using Elixir by frou_dh on Thursday May 07, 2015 @07:50AM (#9504374)
Strictly there is a little hindrance for the non-gopher user because this won't work until they set up a Go workspace, i.e. decided where they want GOPATH to be, set that, and added $GOPATH/bin to PATH to have the executable be runnable.

    $ env -i $(which go) get github.com/schachmat/wego
    package github.com/schachmat/wego: cannot download, $GOPATH not set. For more details see: go help gopath
Re:A command-line weather app built using Elixir by laumars on Thursday May 07, 2015 @07:58AM (#9504407)
Indeed, but that's a separate point. The question was why Go was listed as a dependency and my answer was because it's a source code repository.

Also, you left off GOROOT from your Go environment :)

Re:A command-line weather app built using Elixir by frou_dh on Thursday May 07, 2015 @08:14AM (#9504483)
> The question was why Go was listed as a dependency

You may have read it that way but the question was explicitly referring to "working Go environment"

Re:A command-line weather app built using Elixir by laumars on Thursday May 07, 2015 @08:55AM (#9504664)
Only because that was the terminology used on the Github readme. He was quoting it verbatim rather than asking what environmental variables needed setting. The reason I think this is because he also went on to say "I thought one of golang's selling points was the fact that it created a simple binary." which relates directly to discussions people make about JIT compiled (eg Python, Javascript, etc) vs AOT compiled (eg C++ and Go).

It's also worth noting that you're only specifically discussing environmental variables, where as a development environment is more than just that. Aside having your build tools in PATH (and lets not forget that gcc and make need this just as much as go does), you need supporting shells for the ./config(ure) scripts, any source libraries for C++ includes, and so forth. So you could equally use the same "working [language] environment" terminology to describe C++ - or in fact any other programming language too.

Which is why I think he was asking why he needed Go installed to begin with.

Re:A command-line weather app built using Elixir by frou_dh on Thursday May 07, 2015 @09:45AM (#9504959)
Alright, well hopefully somebody gleans something from our little thread either way.
Re:A command-line weather app built using Elixir by gknoy on Thursday May 07, 2015 @12:01PM (#9506019)
Absolutely. I'm happy to `apt-get install` something, but the conceptual overhead of "let me configure a $language development environment" is high enough that I'm not going to bother just to install this awesome looking tool.

I'd love it if this had been packaged in a way similar to Python or Node tools, where installation is as simple as 'install Python and pip; pip install my-program', and more-experienced users (or those who want source) can clone the git repo.

Re:A command-line weather app built using Elixir by laumars on Friday May 08, 2015 @02:43AM (#9510299)
So request a binary then. You're basically moaning that an open source project is shipping source code.

And FYI, Go is in quite a few distro repos so you might be able to just:

  apt-get install go-lang
  mkdir -p ~/go/src ~go/bin
  export GOPATH=~/go
  go get github.com/schachmat/wego
  go install github.com/schachmat/wego
However considering this is an open source CLI tool, I don't think it's at all unreasonable to expect he user to do a bit more manual work to compile and run this tool from the command line.

In fact, quite frankly, I find it rather disgusting that someone should share their work and source code like this and have others moan simply because they're too bloody lazy to compile it themselves. I mean seriously guys, this is Hacker News, not PC World Magazine.

Re:A command-line weather app built using Elixir by johnmaguire2013 on Monday May 11, 2015 @12:27AM (#9522697)
It actually does work this way. 'Install Go; go get github.com/me/my-program'. Done.
Re:A command-line weather app built using Elixir by ZenSwordArts on Thursday May 07, 2015 @11:07AM (#9505574)
Wow thanks for sharing.. this is really is beautiful!
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @11:55AM (#9505966)
That's really mind blowing! Thanks for sharing this.
Re:A command-line weather app built using Elixir by fit2rule on Thursday May 07, 2015 @07:43AM (#9504341)
Thanks, wego is very beautiful and quite useful!
Re:A command-line weather app built using Elixir by nodata on Thursday May 07, 2015 @07:07AM (#9504193)
It's nice, but it's not beautiful. Let's stop calling everything beautiful.
Re:A command-line weather app built using Elixir by teh_klev on Thursday May 07, 2015 @10:19AM (#9505198)
...and "awesome".
Re:A command-line weather app built using Elixir by lmorris84 on Thursday May 07, 2015 @09:28AM (#9504850)
Should be called "temperature" rather than "weather". 21 degrees and...raining? sunny? any cloud?

Wouldn't call it beautiful - the ascii art is really distracting.

Re:A command-line weather app built using Elixir by anc84 on Thursday May 07, 2015 @08:50AM (#9504630)
Temperature accurate to three decimals? That's kinda silly. It would be more useful to display the "felt temperature".
Re:A command-line weather app built using Elixir by tormeh on Thursday May 07, 2015 @08:53AM (#9504650)
As well as, you know, the weather? Like temperature is an important part of weather, but it's often not even the most important one.
Re:A command-line weather app built using Elixir by davidw on Thursday May 07, 2015 @06:22AM (#9504070)
If you like the ascii characters like that, you might also enjoy figlet: http://www.figlet.org/
Re:A command-line weather app built using Elixir by bshimmin on Thursday May 07, 2015 @06:40AM (#9504107)
You beat me to it, so I'll just add that figlet in combination with the inestimable cowsay (http://en.wikipedia.org/wiki/Cowsay) produces excellent results.
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:11PM (#9506111)
I am aware of figlet but, this project was created while learning Elixir and I wanted to do it myself :)
Re:A command-line weather app built using Elixir by azurelogic on Thursday May 07, 2015 @09:01AM (#9504698)
I'm excited about this not because I want to use it, but because it is a great example of an Elixir app. I'm in the process of learning Elixir, and it was cool to see someone else's code and be able to make sense of most of it. Thanks for posting this!
Re:A command-line weather app built using Elixir by ajanuary on Thursday May 07, 2015 @09:24AM (#9504837)
I don't know Elixir, but it does some questionable things. For instance, it appears to read and process the entire ascii_chars.txt file for each character in the output. It's not a big file, but it wouldn't be difficult to read it once.
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:14PM (#9506141)
I thought of that but for a starter I didn't want to optimise too much. But still it's a good suggestion and I will apply "boy scout rule" for sure!
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:15PM (#9506155)
I know :). I am learning Elixir as well! Glad that you liked it :)
Re:A command-line weather app built using Elixir by erikb on Thursday May 07, 2015 @11:38AM (#9505827)
That's not the weather, that's the temperature. But I like the effort put into making interesting little tools!
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @11:58AM (#9505983)
yeah.. that's true, it's just shows temperature.

Btw, Thanks for your kind words!

Re:A command-line weather app built using Elixir by zaargy on Thursday May 07, 2015 @08:46AM (#9504610)
curl 'http://api.openweathermap.org/data/2.5/weather?q=london&mode... &>/dev/null | jgrep -s main.temp | figlet

Put this in a function. Done.

Gist here since copying and pasting above didn't work. https://gist.github.com/zaargy/384889cb44960e8559d5

Re:A command-line weather app built using Elixir by feld on Thursday May 07, 2015 @08:55AM (#9504662)
My first thought was "pipe into figlet, done."
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:03PM (#9506039)
That's a good one!
Re:A command-line weather app built using Elixir by jalada on Thursday May 07, 2015 @06:55AM (#9504149)
Interesting describing ASCII art as 'beautiful'. You can tell this isn't Designer News :P
Re:A command-line weather app built using Elixir by iamcurious on Thursday May 07, 2015 @10:29AM (#9505266)
Outputting numbers as ASCII art is not beautiful. Can't parse it, can't pipe it, doesn't deserve to be in the command line.
Re:A command-line weather app built using Elixir by baldfat on Thursday May 07, 2015 @07:13AM (#9504220)
I son't know but I love ncurses software and find the actual UI "beautiful since it gets me the information quickly and quickly lets me get things done.

I find my wee-chat with 256 color urxvt with Source Code Pro font in Light Solarized to be the best looking IRC client ever :)

Re:A command-line weather app built using Elixir by feld on Thursday May 07, 2015 @08:57AM (#9504673)
this isn't even ncurses, it's just stdout
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:20PM (#9506205)
LOL!
Re:A command-line weather app built using Elixir by jbverschoor on Thursday May 07, 2015 @10:38AM (#9505328)
Does not work (osx):

  ~/tmp/elixir-weather $ ./weather  Amsterdam

  =INFO REPORT==== 7-May-2015::16:37:56 ===
      application: elixir
      exited: {bad_return,
                  {{elixir,start,[normal,[]]},
                   {'EXIT',
                       {{badmatch,{error,enotsup}},
                        [{elixir,start,2,[{file,"src/elixir.erl"},{line,34}]},
                         {application_master,start_it_old,4,
                             [{file,"application_master.erl"},{line,272}]}]}}}}
      type: temporary
  Failed to start Elixir.
  error: {error,
             {elixir,
                 {bad_return,
                     {{elixir,start,[normal,[]]},
                      {'EXIT',
                          {{badmatch,{error,enotsup}},
                           [{elixir,start,2,[{file,"src/elixir.erl"},{line,34}]},
                            {application_master,start_it_old,4,
                                [{file,"application_master.erl"},
                                 {line,272}]}]}}}}}}
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:01PM (#9506022)
I will look into this issue. Thanks for reporting :)
Re:A command-line weather app built using Elixir by jhwhite on Thursday May 07, 2015 @11:06AM (#9505563)
Ya know, I was just thinking about doing something like this just a couple of days ago, but instead I wrote a python script to get the weather from forecast.io api, then brought that into my tmux status bar.
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:22PM (#9506220)
That's great! would be nice if yo could share the source as well.
Re:A command-line weather app built using Elixir by jhwhite on Thursday May 07, 2015 @01:11PM (#9506630)
Ask and you shall receive! I'm very much a beginner developer so any feedback would be appreciated.

https://gist.github.com/jhwhite/2df093eff1f9bab74144

Re:A command-line weather app built using Elixir by supernintendo on Thursday May 07, 2015 @11:54AM (#9505942)
I'm sorry if this comes across as negative, but this is an example of using the wrong tool for the job, IMO.

I love Erlang and Elixir because BEAM gives me easy concurrency, metaprogramming and best of all, fault tolerance via supervisors. For a service that I need to stay alive, this is great. For a simple command line utility, I'd lean more toward a compiled language like Go, Haskell, Common Lisp, etc.

Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:07PM (#9506067)
I completely understand your point. This is a project I created while learning Elixir.
Re:A command-line weather app built using Elixir by techdragon on Thursday May 07, 2015 @08:21AM (#9504508)
I'm going to be honest... This is an ugly looking pig of a command line tool. The giant ascii art looks bad and does nothing for its usefulness or usability.
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:05PM (#9506054)
I am sorry for that. It was a hobby project of mine when learning Elixir and I got excited about it.
Re:A command-line weather app built using Elixir by masukomi on Thursday May 07, 2015 @12:11PM (#9506108)
I've got nothing against it. it's a fun little hobby app, but yeah, I've got to agree with the commenter above this is FAR from any standard definition of a "beautiful" app.
Re:A command-line weather app built using Elixir by tacticiankerala on Thursday May 07, 2015 @12:26PM (#9506252)
I admit that :)
Re:A command-line weather app built using Elixir by baldfat on Thursday May 07, 2015 @07:09AM (#9504197)
I have used weather an old command line utility for years.

http://fungi.yuggoth.org/weather/

Pretty cool to track the temperature with your own home temperature.

Re:A command-line weather app built using Elixir by grimmdude on Thursday May 07, 2015 @10:58AM (#9505506)