Hacker Newsnew | past | comments | ask | show | jobs | submit | more CodeIsTheEnd's commentslogin

TIL: #method(:method_name) in Ruby

I'm a big fan of Ruby, and feel like I know the language pretty well, but, my goodness, I don't know how I've never come across this one before. THIS is something that feels like magic!!

    [1]> 3.method(:days).source_location
    => [".../lib/active_support/core_ext/numeric/time.rb", 37]

    [2]> puts 3.method(:days).comment
    # Returns a Duration instance matching the number of days provided.
    #
    #   2.days # => 2 days
    => nil

    [3]> puts 3.method(:days).source
      def days
        ActiveSupport::Duration.days(self)
      end
    => nil
https://ruby-doc.org/core-3.1.1/Method.html


EDIT: Wilfred IS the original author [3]; my apologies.

Not to discredit Wilfred (it looks like he's taken over the project as the maintainer), but, based on the historical contributions [1], it looks like it was originally developed by Max Brunsfeld, who also created Tree-sitter. [2]

[1]: https://github.com/Wilfred/difftastic/graphs/contributors

[2]: https://github.com/tree-sitter/tree-sitter

[3]: https://github.com/Wilfred/difftastic/commit/958033924a2dea7...


I think the contributor graph is misleading, and that he's using git-subtree to vendor tree-sitter, which makes it look like others have contributed more to the project.


Oops, I think you're right! Thank you for pointing that out.

My apologies to Wilfred.


Hey, HN! Creator here!

I started building Plain Text Sports last year when I was watching an NFL playoff game in rural southwest Wisconsin. We had poor TV reception -- the image was going in-and-out -- and the local radio station was mostly static. I tried to check ESPN, but the loading bar was as frozen as the ground outside. I then had the idea for a website designed for the pure sports fan: no ads, no images, just scores, play-by-play and stats, with a simple information-dense display.

I initially added support for the NBA so I could follow my beloved Milwaukee Bucks. I posted it to /r/nba, got over 600 upvotes in a few hours, and got perma-banned for self-promotion. (I did a Show HN too, but it didn't take off. [1]) Over the following months I added NHL, MLB, NFL, college basketball and football, and added standings and team schedules so it could really be a one-stop-shop for my sporting needs. Just this past month I added MLS and NWSL (National Women's Soccer League). I plan on adding the WNBA and the Premier League later this year too.

Obviously I designed the site with minimalism and efficiency in mind, as a reaction to the bloated web we see today. We don't need heaps of JavaScript just to display a bit of text, nor do we need half-a-dozen sites tracking our "engagement", and our "retention". People just want to get the information they're looking for, as fast as possible. Technology shouldn't get in the way.

Despite the austere presentation, I'm really proud of the design of the site. As a commenter noted, it's not actually plain text, but does use some CSS and a tiny bit of JavaScript (sue me!). But there are a lot of small details that I put a lot of effort into: the game times on the front page automatically show up in your local time zone, and the boxes automatically expand to fit long time-zones. For the NBA, the raw play-by-play data I get is very granular. A steal, for example, is both a turnover by the offensive player, and a steal for the defensive player, but I combine those into a single event in the timeline. For the NFL, I draw an ASCII drawing of the field showing the progress of the most recent play [2]. When a team wins a championship, they get an ASCII trophy and a dedicated spot on the front-page for the next week. It's been really fun trying to figure out how to pack as much information as possible into a 45 column-wide display.

A streamer I watch on Twitch [3] who does marketing at Nvidia also had a competition amongst his viewers to make their own ads, and that led me down another rabbit hole of fun "plain-text" videos. [4][5][6].

Plain Text Sports also led to my next project. I get a lot of data from publicly accessible, but undocumented JSON APIs, and it was frustrating digging through giant JSON files trying to understand how certain situations were represented. That led me to build jless [7], a command-line JSON viewer, which made it to the front page last month.

[1]: Original Show HN: https://news.ycombinator.com/item?id=26310314

[2]: ASCII football field: https://twitter.com/CodeIsTheEnd/status/1436003783327293452

[3]: Atrioc, Nvidia marketing streamer: https://twitch.tv/atrioc

[4]: Never Miss Moment Ad: https://www.youtube.com/watch?v=9t1qY0vOJWc

[5]: Bucks Championship Run: https://www.youtube.com/watch?v=4WHcP4PTBHY

[6]: Wisconsin Sports Ad: https://www.youtube.com/watch?v=dLsm0MirOEg

[7]: jless, a command-line JSON viewer: https://jless.io


Love it and found it via Gruber's post.

Question: why not use a proportional font for all things other than the score? It would make readability much better. Is the output being mapped to individual character widths, that's why?

EDIT: One more question, is there a URL I can share that enables dark mode? e.g. https://plaintextsports.com/?mode=dark


Also, Nanum Gothic Coding has a fantastic monospace font that is highly readable. Might be worthwhile for you to consider using this free font since it will greatly increase readability.

It also has the added benefit that the "+" and the "---" align (I only mention this because I noticed the system monospace font on macOS does not align at the box score border "+----")

https://fonts.google.com/specimen/Nanum+Gothic+Coding?catego...


Great work on the website. I really like the minimalist style. Will definitely use it once you have the Premier League on there.

I’ve actually considered building a similar type of site for a while but wasn’t sure how to get the real-time sports score updates.

Do you have to pay for that data?


Very cool, thanks for making this! I'm curious if you have any plans to monetize the site, or at least cover your costs? I know the live sports data feeds are not that cheap!


This is really cool! Can you talk a bit about the backend: where is the data coming from, how often do you fetch it etc?


Thanks for your work. I've been using your site for a while. Amazing how in 2022, with 4G widely available, it's that difficult to check a game score every five minutes while you're working. It feels as if sites like ESPN optimize their sites to minimize the probability that they are useful.


This is awesome. Do you mind sharing the json data source you're using for the NBA data?


wow small world- you have a poster up in your window with the URL, right? i think you live around the corner from me!


I sure do! Knock if you ever want some stickers!


Is there a WYSIWYG (what-you-see-is-what-you-get [1]) document editor that is built on a foundation of HTML/CSS, and explicitly surfaces operations that map to CSS features, like flexbox? Changing the base style just means writing CSS rules for the `p` tag! And it could maybe even encourages component / class-based styling? I imagine it could be used for creating things that may get printed out, but will also see a longer life on a web page. You could even have explicit media queries to apply only when printing! [2]

I think of something like creating a good looking resume, which may include light graphic design elements like divider lines, and might not have a strictly linear layout and put some information in a sidebar. Making something look good in Word can be really frustrating, and require jiggering with margins and column layouts. It may fall apart when you try to add a new job. It's almost a joke that if you want a good looking resume, you should use LaTeX, but that's incredibly inaccessible. So many more people know basic HTML and CSS!

I think a lot of website builders (like Webflow [3] ?) expose a lot of underlying HTML/CSS, but I suspect they also support a lot more ad-hoc graphic design elements that can really make the underlying HTML document a total mess.

[1]: https://en.wikipedia.org/wiki/WYSIWYG

[2]: https://developer.mozilla.org/en-US/docs/Web/CSS/@media#prin...

[3]: https://webflow.com/


Guilty [1]. But it's really hard to handle both light and dark color themes! On a dark terminal you're probably more likely to use the "Bright" variants when using the default 16 color palette, but then you'll have less contrast in a light theme. Some color schemes intentionally invert the "bright" colors and makes them darker for a light colored scheme. This is what Gruvbox [2] does, but most other palettes don't. I also have an issue with Solarized which makes some of the Bright colors almost exactly the same as the foreground or background, which can make text printed in certain colors seem invisible.

I've used ANSI codes to invert colors (which works pretty well for highlighting), and dim colors, but those can't solve everything.

[1]: https://github.com/PaulJuliusMartinez/jless/issues/4 [2]: https://github.com/morhetz/gruvbox


The design intent for Solarized is to minimize contrast, so this may lie somewhere between “you’re holding it wrong” territory, and aggressive cargo-culting advertising making this theme show up everywhere as an implied default good option. It is a nice set of color choices, but is not really appropriate for many situations where it gets used.


Especially when no environment variable tells you whether to use light or dark.



> On a dark terminal you're probably more likely to use the "Bright" variants when using the default 16 color palette, but then you'll have less contrast in a light theme.

The bright theme should invert the "dark" and "light" colors.


(Author here) Homebrew support was added entirely with macOS in mind, but Homebrew for Linux uses the same repository of formulas as Homebrew for macOS [1], so you get Linux support for free. I included Homebrew for Linux because it's an option, but I don't want it to be the only option.

I guess I should explicitly say in the documentation that help would be appreciated in adding support for other package managers. I definitely want jless available through the most standard avenues.

[1]: https://github.com/Homebrew/homebrew-core/blob/master/Formul...


Hi Author :-) Please note that I am VERY much appreciating the application and effort, and this was not meant as criticism. I saw you mentioned you're not a Linux person which is cool - I get why the brew is there.

It's just that I never really understood why there even IS a homebrew for linux.

I'm pretty sure you'll find yourself with multo-distro repository presence soon enough since your app is useful indeed.


Oops, sorry, I haven't actually made a new release with those commands yet. I'll need to have better discipline maintaining a separate `latest` branch for the website...


Sorry! Someone already filed an issue about this [1], but I haven't had time to investigate exactly what is appropriate to put there. I don't use Linux, nor have I ever released and distributed open-source software before, so I'm just kinda guessing here -- other people have added the project to various package managers, not me.

Installing via Linux Homebrew is simply listed as an option because it's available as a Homebrew formula. And the option to install via cargo is also noted.

[1]: https://github.com/PaulJuliusMartinez/jless/issues/46


As mentioned in this issue you should not give an install command since it's in the AUR. You can just mention it's available in the AUR and provide a link to the package instead: https://aur.archlinux.org/packages/jless


Author here! When I originally submitted it, it didn't get a lot of traction (it got on the front-page via the second chance pool a couple days later), and I definitely regretted not including "written in Rust" in the title. I'm acutely aware of HN's love of Rust, and the subsequent grumbling about always bringing it up that something is written in Rust, so I left it out with the false illusion that not mentioning it would make it more "pure" or something.

But I was also pretty confident that I made something useful, and, in hindsight, I don't think I should have preemptively felt bad about using some "cheap" form of marketing to get people to see it. I have really conflicting thoughts about marketing and self-promotion from my experience trying to show people my other project, plaintextsports.com [1] (live sports scores in plain text with no ads or trackers so it loads instantly! I think the HN crowd would love it!). There's a weird line between marketing and advertising and self-promotion, where one is "ok", but the other is frowned upon. It's also a tale as old as time that the better marketed but technically inferior product wins out. (AC vs DC initially, Betamax vs VHS!) How much of success is being brazen enough to ignore those norms and shamelessly promote something? Should it be considered shameful to promote it in the first place?

In this case, being written in Rust is definitely a feature, as least when comparing tools! fx [2], a similar tool that made the front-page a couple months ago runs using Node, and I'm sure jless can handle bigger files and uses less memory (though admittedly I haven't actually verified this).

[1]: https://plaintextsports.com

[2]: https://news.ycombinator.com/item?id=29861043


You did make something useful. Don't feel bad about the title here. It's not like you're selling this as a rewrite of something that already exists with the only difference being that it's Rust. (And certainly not like the worse case of that where the selling point is "rewritten in Rust" but it actually has fewer features or is less user friendly than the original)


Content quality is key. The post "We're choosing Rust, and not Go, C++, or Node.js" got flagged a few hours ago after reaching the front page briefly: https://news.ycombinator.com/item?id=30465632 Although it reached some conclusions similar to those I might reach, it also (as another poster put it) "invited language flame wars" and contained some shoddy reasoning, which I and others did not appreciate.

I like reading posts touching on Rust which lead to thought-provoking and civil discussions — especially when the choice of Rust is germane — and I appreciate knowing that Rust is involved from the titling/marketing. Thanks for your good work!


This is a wonderful tool!


This reminds me of a very poor interview question I asked a couple of times (and then never asked again because it is a terrible, terrible, interview question).

The snake cube puzzle [1] is a puzzle where you have to fold up a string of 27 cubes, with fixed "turns" like the shapes in the OP, into a 3x3x3 grid.

The goal was not to find a solution to the puzzle, but to find the smallest 2d area the snake could fit into without folding against itself. It turned into a modeling problem (how do you represent the puzzle in code?) and a recursion problem (try all possible folds), but, uh, even with a physical puzzle to play with, it was a little too abstract

A commenter on the link below asked another question over 13 years ago: can the puzzle be folded into a plane without any holes? Obviously if you just lay out the puzzle from end to end it will be in a plane, and without any holes, so maybe the question should be: what is the smallest 2d area the snake can fit into without creating any holes?

[1]: https://mypuzzles.wordpress.com/2008/09/07/the-snake-cube/


27x1 would again be the smallest 2d area.


Consider applying for YC's Winter 2027 batch! Applications are open till November 2.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: