项目作者: james-ransom

项目描述 :
Remove HN comments that have negative points
高级语言: Ruby
项目地址: git://github.com/james-ransom/hn-delete-negative-point-comments.git


What it does

Deletes your HN comments automatically that have negative points

WHY do this

Ever post a comment you regret? Often these comments have negative points. If you aren’t monitoring the comment closely you will lose your ability to delete the comment — making it permanent :(

Install dependencies:

  1. bundle install

How to run it

To use:

  1. ruby run.rb [YOURUSERNAME] [YOURPASSWORD] [MIN_NUMBER_OF_POINTS]

let’s delete comments less than one point

  1. ruby run.rb USERNAME PASSWORD 1

let’s delete comments less than two points

  1. ruby run.rb USERNAME PASSWORD 2

How to get it to run automatically?

add rvm properties to your cronjob file [backup your crontab first!]

  1. rvm cron setup;

open crontab in your Terminal:

  1. crontab -e

Add this line:

  1. * * * * * cd [path to code source]; ruby run.rb [YOURUSERNAME] [YOURPASSWORD] [MIN_NUMBER_OF_POINTS]

Example

  1. cd /Users/username/hn-delete-negative-point-comments; ruby run.rb throwaway203821 throwawaypassword 1 >> /tmp/delete.log

On macOS to get the ruby path, type in your Terminal:

  1. which ruby

On macOS if you have problems with crontab with “Operation not permitted”

  1. http://osxdaily.com/2018/10/09/fix-operation-not-permitted-terminal-error-macos/

For more help with crontab

  1. https://ole.michelsen.dk/blog/schedule-jobs-with-crontab-on-mac-osx.html

For more help with rvm and cron

  1. https://stackoverflow.com/questions/5680561/need-to-set-up-rvm-environment-prior-to-every-cron-job

Watch it run (Assuming you pipe it to /tmp/delete.log)

  1. $ tail -f /tmp/delete.log
  2. No bad comments....
  3. No bad comments....
  4. No bad comments....
  5. No bad comments....
  6. Deleting comment: 18588594
  7. No bad comments....

Tests

  1. ruby test.rb