Skip to content

Instantly share code, notes, and snippets.

@shawwn
Created January 21, 2019 06:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawwn/319af7a1f06951f0d6dcb1604f1e7cbe to your computer and use it in GitHub Desktop.
Save shawwn/319af7a1f06951f0d6dcb1604f1e7cbe to your computer and use it in GitHub Desktop.
#!/usr/bin/env node
// Replace YOUR_API_KEY at the bottom of this file with the key diffbot sends you during signup.
// usage: diffbot-summary <URL>
//
//
// $ diffbot-summary 'https://news.ycombinator.com/item?id=4399108'
// {
// "date": "Fri, 17 Aug 2012 00:00:00 GMT",
//
// "icon": "https://news.ycombinator.com/favicon.ico",
//
// "html": "<p>This, and many of the suggestions in the original thread, and pg's default response, are all falling into the same trap: they are attempting to fix a people problem using technical solutions.</p>\n<p>Technology can make community management easier. Better algorithms and visual design and so on can improve the way that a community polices itself. But, I think eventually you'll run into vanishing returns from that kind of stuff. (I don't have any good science for this, but I've been spending too much time online since the dial-up BBS days, and community development is one of my interests.)</p>\n<p>Eventually every community needs one or more managers, or gardeners (<a href=\"http://lesswrong.com/lw/c1/wellkept_gardens_die_by_pacifism/\">http://lesswrong.com/lw/c1/wellkept_gardens_die_by_pacifism/</a>) -- people who have been around a long time, who embody the &quot;spirit&quot; of the site, and who have, not absolute, but special influence on the community. (RiderOfGiraffes immediately comes to mind; I really wish he was still around.)</p>\n<p>This is absolutely analogous to Google attempting to avoid customer service completely by piling on more and more automated systems. While those systems help, they can't yet replace an actual customer service department -- and I think the frequent complaints from people who've been impacted by Google's lack of customer service bears this out.</p>\n<p>I like some of the suggestions in this post, but I don't think that they can resolve the main issue with HN at the moment: it has grown to a size which needs one or more community managers.</p>\n<p>There are some architectural issues too. I think the current trend in online forums, where new things are always better than good things, is ultimately a step backwards in terms of encouraging thoughtful discussion (<a href=\"http://www.robsheldon.com/conversations-online/\">http://www.robsheldon.com/conversations-online/</a>). If a really interesting item comes up on HN that requires, say, a solid hour to compose a thoughtful response -- something very technical that would benefit from some number crunching -- there is very little motivation to commit the time to write that response. By the time it's written and posted, the site has moved on to the next new thing. However, the first person to respond to an item with a quick, witty, or snarky response gets rewarded with lots of attention.</p>\n<p>And that is a problem that can not be resolved by any of the suggestions so far.</p>",
//
// "text": "This, and many of the suggestions in the original thread, and pg's default response, are all falling into the same trap: they are attempting to fix a people problem using technical solutions.\nTechnology can make community management easier. Better algorithms and visual design and so on can improve the way that a community polices itself. But, I think eventually you'll run into vanishing returns from that kind of stuff. (I don't have any good science for this, but I've been spending too much time online since the dial-up BBS days, and community development is one of my interests.)\nEventually every community needs one or more managers, or gardeners (http://lesswrong.com/lw/c1/wellkept_gardens_die_by_pacifism/) -- people who have been around a long time, who embody the \"spirit\" of the site, and who have, not absolute, but special influence on the community. (RiderOfGiraffes immediately comes to mind; I really wish he was still around.)\nThis is absolutely analogous to Google attempting to avoid customer service completely by piling on more and more automated systems. While those systems help, they can't yet replace an actual customer service department -- and I think the frequent complaints from people who've been impacted by Google's lack of customer service bears this out.\nI like some of the suggestions in this post, but I don't think that they can resolve the main issue with HN at the moment: it has grown to a size which needs one or more community managers.\nThere are some architectural issues too. I think the current trend in online forums, where new things are always better than good things, is ultimately a step backwards in terms of encouraging thoughtful discussion (http://www.robsheldon.com/conversations-online/). If a really interesting item comes up on HN that requires, say, a solid hour to compose a thoughtful response -- something very technical that would benefit from some number crunching -- there is very little motivation to commit the time to write that response. By the time it's written and posted, the site has moved on to the next new thing. However, the first person to respond to an item with a quick, witty, or snarky response gets rewarded with lots of attention.\nAnd that is a problem that can not be resolved by any of the suggestions so far.",
//
// "type": "article",
//
// "title": "A Proposal To Improve Hacker News",
//
// "url": "https://news.ycombinator.com/item?id=4399108",
//
// "tags": [
// "Technology"
// ]
// }
var fs = require("fs");
var child_process = require("child_process");
var read_file = function (path) {
return fs.readFileSync(path, "utf8");
};
var write_file = function (path, data) {
return fs.writeFileSync(path, data, "utf8");
};
var file_exists63 = function (path) {
return fs.existsSync(path, "utf8") && fs.statSync(path).isFile();
};
var directory_exists63 = function (path) {
return fs.existsSync(path, "utf8") && fs.statSync(path).isDirectory();
};
var get_environment_variable = function (name) {
return process.env[name];
};
var write = function (x) {
var __out = process.stdout;
return __out.write(x);
};
var exit = function (code) {
return process.exit(code);
};
var argv = process.argv.slice(2);
var reload = function (module) {
delete require.cache[require.resolve(module)];
return require(module);
};
var run = function (command) {
return child_process.execSync(command).toString();
};
var shellquote = function (s) {
return " '" + s.replace(/'/g, "'\"'\"'") + "'";
}
var shellcmd = function (cmd, args) {
return cmd + args.map(shellquote).join(" ");
}
var shell = function (cmd) {
var args = Array.prototype.slice.call(arguments, 1);
return run(shellcmd(cmd, args));
}
write(shell("curl", "-fsSL", "http://www.diffbot.com/api/article?token=YOUR_API_KEY&url=" + encodeURIComponent(argv[0])));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment