Convert Figma logo to code with AI

donnemartin logohaxor-news

Browse Hacker News like a haxor: A Hacker News command line interface (CLI).

3,972
165
3,972
41

Top Related Projects

Computing-focused community centered around link aggregation and discussion

11,306

Documentation and Samples for the Official HN API

Some of the hidden norms about Hacker News not otherwise covered in the Guidelines and the FAQ.

:books: Find your next book to read!

Quick Overview

Haxor News is a command-line interface (CLI) for browsing and interacting with Hacker News. It provides a terminal-based experience for reading articles, comments, and user profiles from the popular tech news aggregator. The project aims to offer a fast and efficient way to access Hacker News content without leaving the command line.

Pros

  • Efficient terminal-based browsing of Hacker News content
  • Customizable viewing options and filters
  • Supports various Hacker News features like comments, user profiles, and post categories
  • Lightweight and fast compared to web-based browsing

Cons

  • Limited to text-based interface, lacking visual elements of the web version
  • Requires command-line familiarity, which may be challenging for some users
  • May not always reflect real-time updates as quickly as the website
  • Dependent on Hacker News API availability and rate limits

Code Examples

# Viewing top stories
$ hn top

# Reading comments for a specific post
$ hn view 1234 -c

# Filtering stories by a specific user
$ hn user pg
# Searching for articles with a specific keyword
$ hn search "python"

# Opening a story in the default web browser
$ hn view 5678 -b

# Displaying user information
$ hn user info johndoe

Getting Started

To get started with Haxor News, follow these steps:

  1. Install the package using pip:

    $ pip install haxor-news
    
  2. Run the hn command to start using Haxor News:

    $ hn
    
  3. Use various commands to interact with Hacker News content:

    $ hn top            # View top stories
    $ hn view 1234      # View a specific story
    $ hn user johndoe   # View user information
    

For more detailed usage instructions and available commands, refer to the project's documentation on GitHub.

Competitor Comparisons

Computing-focused community centered around link aggregation and discussion

Pros of Lobsters

  • Full-featured web application with a user interface
  • Community-driven project with multiple contributors
  • Includes features like user accounts, commenting, and tagging

Cons of Lobsters

  • More complex setup and deployment
  • Requires a web server and database to run
  • Steeper learning curve for new contributors

Code Comparison

Haxor-news (Python):

def print_item_and_metadata(item):
    print(format_item(item))
    print(format_item_metadata(item))

Lobsters (Ruby):

def show
  @story = find_story!
  @comments = @story.comments.includes(:user, :story, :hat)
  @title = @story.title
end

Summary

Haxor-news is a command-line interface for browsing Hacker News, while Lobsters is a full-featured web application for running a community-driven news site. Haxor-news is simpler to set up and use, but Lobsters offers a more comprehensive feature set and a graphical user interface. The code comparison shows that Haxor-news is written in Python and focuses on displaying items, while Lobsters is written in Ruby and handles more complex web application logic.

11,306

Documentation and Samples for the Official HN API

Pros of HackerNews/API

  • Official API provided by Hacker News, ensuring reliability and up-to-date functionality
  • Comprehensive documentation with detailed endpoints and usage examples
  • Supports real-time updates through Firebase integration

Cons of HackerNews/API

  • Requires additional implementation to create a user-friendly interface
  • Limited to raw data retrieval, lacking built-in formatting or display options
  • May require more complex setup for developers new to API integration

Code Comparison

HackerNews/API:

import requests

url = "https://hacker-news.firebaseio.com/v0/item/8863.json"
response = requests.get(url)
print(response.json())

haxor-news:

from haxor_news import HaxorNews

hn = HaxorNews()
hn.view('top')

The HackerNews/API example demonstrates raw data retrieval, while haxor-news provides a more user-friendly interface for viewing top stories directly in the terminal. haxor-news abstracts the API calls and data formatting, making it easier for users to interact with Hacker News content without dealing with the underlying API implementation.

Some of the hidden norms about Hacker News not otherwise covered in the Guidelines and the FAQ.

Pros of hacker-news-undocumented

  • Focuses on documenting undocumented features of the Hacker News API
  • Provides detailed explanations and examples of hidden API endpoints
  • Useful for developers looking to leverage advanced HN API capabilities

Cons of hacker-news-undocumented

  • Not a functional application or tool, primarily documentation
  • Less user-friendly for those seeking a ready-to-use HN interface
  • May require more technical knowledge to implement the documented features

Code Comparison

haxor-news:

def print_item_comments(item):
    for comment in item.comments:
        print_comment(comment)
        print_comments(comment.comments)

hacker-news-undocumented:

# No direct code comparison available as hacker-news-undocumented
# is primarily documentation, not a functional application

Summary

haxor-news is a command-line interface for browsing and interacting with Hacker News, offering a user-friendly tool for HN enthusiasts. On the other hand, hacker-news-undocumented serves as a comprehensive resource for developers interested in exploring undocumented features of the HN API. While haxor-news provides a ready-to-use application, hacker-news-undocumented offers valuable insights for those looking to build custom HN-related tools or integrate advanced API features into their projects.

:books: Find your next book to read!

Pros of Mind-Expanding-Books

  • Curates a comprehensive list of books across various topics, providing a valuable resource for self-improvement and learning
  • Encourages community contributions, allowing for a diverse and ever-growing collection of book recommendations
  • Organizes books into categories, making it easy for users to find relevant reads based on their interests

Cons of Mind-Expanding-Books

  • Lacks interactive features or tools for engaging with the content directly
  • Does not provide real-time updates or news like Haxor-News does for Hacker News
  • Requires manual updates and curation, which may lead to less frequent additions compared to an automated system

Code Comparison

While a direct code comparison is not particularly relevant for these repositories due to their different natures, we can highlight some key differences in their structure:

Mind-Expanding-Books:

## Economics
| Name | Author | Goodreads Rating | Year Published |  
|------|--------|------------------|----------------|
| Freakonomics | Steven D. Levitt, Stephen J. Dubner | [3.98](https://www.goodreads.com/book/show/1202.Freakonomics) | 2005 |

Haxor-News:

class HackerNewsCli(object):
    def __init__(self):
        self.hacker_news_api = HackerNewsApi()
        self.paginate = Paginate()
        self.config = Config()

Mind-Expanding-Books uses markdown to organize book information, while Haxor-News is a Python-based command-line interface for interacting with Hacker News.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Imgur

Build Status

PyPI version PyPI License

haxor-news

Coworker who sees me looking at something in a browser: "Glad you're not busy; I need you to do this, this, this..."

Coworker who sees me staring intently at a command prompt: Backs away, slowly...

-Source

Check out the haxor-news discussion in this Hacker News post.

haxor-news brings Hacker News to the terminal, allowing you to view/filter the following without leaving your command line:

  • Posts
  • Post Comments
  • Post Linked Web Content
  • Monthly Hiring and Freelancers Posts
  • User Info
  • Onions

haxor-news helps you filter the large number of comments that popular posts generate.

  • Want to expand only previously unseen comments?
    • -cu/--comments_unseen
  • How about recent comments posted in the past 60 minutes?
    • -cr/--comments_recent
  • Filter comments matching a regex query?
    • -cq/--comments_query [query]

Imgur

Job hunting or just curious what's out there? Filter the monthly who's hiring and freelancers post:

$ hn hiring "(?i)(Node|JavaScript).*(remote)" > remote_web_jobs.txt

Combine haxor-news with pipes, redirects, and other command line utilities. Output to pagers, write to files, automate with cron, etc.

haxor-news comes with a handy optional auto-completer with interactive help:

Imgur

Index

General

Features

Installation and Tests

Misc

Syntax

Usage:

$ hn <command> [params] [options]

Auto-Completer and Interactive Help

Optionally, you can enable fish-style completions and an auto-completion menu with interactive help:

$ haxor-news

If available, the auto-completer also automatically displays comments through a pager.

Within the auto-completer, the same syntax applies:

haxor> hn <command> [params] [options]

Imgur

Imgur

Customizable Highlighting

You can control the ansi colors used for highlighting by updating your ~/.haxornewsconfig file.

Color options include:

'black', 'red', 'green', 'yellow',
'blue', 'magenta', 'cyan', 'white'

For no color, set the value(s) to None.

Imgur

Commands

Imgur

View Posts

View the Top, Best, Show, Ask, Jobs, New, and Onion posts.

Usage:

$ hn [command] [limit]  # post limit default: 10

Examples:

$ hn top
$ hn show 20

Imgur

View a Post's Linked Web Content

After viewing a list of posts, you can view a post's linked web content by referencing the post #.

The HTML contents of the post's link are formatted for easy-viewing within your terminal. If available, the formatted output is sent to a pager.

See the View in a Browser section to view the contents in a browser instead.

Usage:

$ hn view [#]

Example:

$ hn view 1
$ hn view 8

Imgur

View and Filter a Post's Comments

View All Comments

After viewing a list of posts, you can view a post's comments by referencing the post #.

Examples:

$ hn view 8 -c
$ hn view 8 --comments > comments.txt

Paged Comments

If running with the auto-completer, comments are automatically paginated. To get the same pagination without the auto-completer, append | less -r:

$ hn view 8 -c | less -r

Imgur

Filter on Unseen Comments

Filter comments to expand only those you have not yet seen. Unseen comments are denoted with a [!] and are fully expanded.

Seen comments will be truncated with [...] and will be shown to help provide context to unseen comments.

Examples:

$ hn view 8 -cu
$ hn view 8 --comments_unseen | less -r

Imgur

Filter on Recent Comments

Filter comments to expand only those posted within the past 60 minutes.

Older comments will be truncated with [...] and will be shown to help provide context to recent comments.

Examples:

$ hn view 8 -cr | less -r
$ hn view 8 --comments_recent

Imgur

Filter with Regex

Filter comments based on a given regular expression query.

Examples:

$ hn view 2 -cq "(?i)programmer" | less -r
$ hn view 2 --comments_regex_query "(?i)programmer" > programmer.txt

Case insensitive regex: (?i)

Imgur

Hide Non-Matching Comments

When filtering comments for unseen, recent, or with regex, non-matching comments are collapsed to provide context. To instead hide non-matching comments, pass the -ch\--comments_hide flag. Hidden comments will be displayed as ..

Example:

$ hn view 8 -cu -ch | less -r

Imgur

Filter the Monthly Hiring Post

Hacker News hosts a monthly hiring post where employers post the latest job openings.

Usage:

$ hn hiring [regex filter]

Examples:

$ hn hiring ""
$ hn hiring "(?i)JavaScript|Node"
$ hn hiring "(?i)(Node|JavaScript).*(remote)" > remote_jobs.txt

Case insensitive regex: (?i)

Imgur

To search a different monthly hiring post other than the latest, use the hiring post id.

Usage:

$ hn hiring [regex filter] [post id]

Filter the Freelancers Post

Hacker News hosts a monthly freelancers post where employers and freelancers post availabilities.

Usage:

$ hn freelance [regex filter]

Examples:

$ hn freelance ""
$ hn freelance "(?i)JavaScript|Node"
$ hn freelance "(?i)(Node|JavaScript).*(remote)" > remote_jobs.txt

Case insensitive regex: (?i)

Imgur

To search a different monthly hiring post other than the latest, use the hiring post id.

Usage:

$ hn freelance [regex filter] [post id]

Combine With Pipes and Redirects

Output to pagers, write to files, automate with cron, etc.

Examples:

$ hn view 1 -c | less
$ hn freelance "(?i)(Node|JavaScript).*(remote)" > remote_jobs.txt

Imgur

View User Info

Usage:

$ hn user [user id]

Imgur

View Onions

Usage:

$ hn onion [limit]  # post limit default: all

Imgur

View in a Browser

View the linked web content or comments in your default browser instead of your terminal.

Usage:

$ hn <command> [params] [options] -b
$ hn <command> [params] [options] --browser

Windows Support

haxor-news has been tested on Windows 10.

Pager Support

Pager support on Windows is more limited as discussed in the following ticket. Users can direct output to a pager with the | more command:

$ hn view 1 -c | more

Config File

On Windows, the .haxornewsconfig file can be found in %userprofile%. For example:

C:\Users\dmartin\.haxornewsconfig

cmder and conemu

Although you can use the standard Windows command prompt, you'll probably have a better experience with either cmder or conemu.

Installation

Pip Installation

PyPI version PyPI

haxor-news is hosted on PyPI. The following command will install haxor-news:

$ pip install haxor-news

You can also install the latest haxor-news from GitHub source which can contain changes not yet pushed to PyPI:

$ pip install git+https://github.com/donnemartin/haxor-news.git

If you are not installing in a virtualenv, run with sudo:

$ sudo pip install haxor-news

Once installed, run the optional haxor-news auto-completer with interactive help:

$ haxor-news

Run commands:

$ hn <command> [params] [options]

Virtual Environment Installation

It is recommended that you install Python packages in a virtualenv to avoid potential issues with dependencies or permissions.

To view haxor-news virtualenv installation instructions, click here.

Mac OS X 10.11 El Capitan Users

There is a known issue with Apple and its included python package dependencies (more info at https://github.com/pypa/pip/issues/3165). We are investigating ways to fix this issue but in the meantime, to install haxor-news, you can run:

$ sudo pip install haxor-news --upgrade --ignore-installed six

Supported Python Versions

  • Python 2.6
  • Python 2.7
  • Python 3.3
  • Python 3.4
  • Python 3.5
  • Python 3.6
  • Python 3.7

Supported Platforms

  • Mac OS X
    • Tested on OS X 10.10
  • Linux, Unix
    • Tested on Ubuntu 14.04 LTS
  • Windows
    • Tested on Windows 10

Developer Installation

If you're interested in contributing to haxor-news, run the following commands:

$ git clone https://github.com/donnemartin/haxor-news.git
$ pip install -e .
$ pip install -r requirements-dev.txt
$ haxor-news
$ hn <command> [params] [options]

Continuous Integration

Build Status

Continuous integration details are available on Travis CI.

Unit Tests and Code Coverage

Run unit tests in your active Python environment:

$ python tests/run_tests.py

Run unit tests with tox on multiple Python environments:

$ tox

Documentation

Source code documentation will soon be available on Readthedocs.org. Check out the source docstrings.

Run the following to build the docs:

$ scripts/update_docs.sh

Contributing

Contributions are welcome!

Review the Contributing Guidelines for details on how to:

  • Submit issues
  • Submit pull requests

Credits

Contact Info

Feel free to contact me to discuss any issues, questions, or comments.

My contact info can be found on my GitHub page.

License

I am providing code and resources in this repository to you under an open source license. Because this is my personal repository, the license you receive to my code and resources is from me and not my employer (Facebook).

License

Copyright 2015 Donne Martin

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.