使用Mathematica和StackOverflow API来关注Mathematica的新问题 [英] Watching for new Mathematica questions using Mathematica and the StackOverflow API

查看:150
本文介绍了使用Mathematica和StackOverflow API来关注Mathematica的新问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

除非维扎德先生正在休假,否则很难克服这种似乎无所不能和无所不知的现象.我们如何使用Mathematica和StackOverflow API超越他?

Unless Mr.Wizard is on vacation, it is pretty difficult to beat this phenomenon which seems to be gifted with omnipresence and omniscience. How can we outdo him using Mathematica and the StackOverflow API?

推荐答案

这是Sjoerd解决方案的一种变体.

Here's a variation on Sjoerd's solution.

主要区别是使用停靠的单元格而不是弹出对话框.该单元格具有指向新帖子的链接,以及一个将停靠的单元格清除为先前状态的按钮.

The main difference is to use a docked cell instead of a popup dialog. The cell has a link to the new post, as well as a button that will clear the docked cell to the previous state.

另一个区别是使用问题ID而不是标题来确定新帖子.我知道标题有时会被编辑,因此在这种情况下,这会触发为新帖子.

The other difference is to use the question ID instead of the title for determining new posts. I know that titles get edited sometimes, so this trigger as a new post in that case.

storedTitle = "";
storedID = 0;
mySOWatchTask = 
  CreateScheduledTask[{lastTitle, 
     lastID} = {"title", 
      "question_id"} /. ("questions" /. 
        Import["http://api.stackoverflow.com/1.1/questions?key=       \
         QEpjCjsXYE6s_kZEkFr4Lw&page=1&pagesize=1&sort=creation&\
tagged=                mathematica", "JSON"])[[1]];
   If[lastID != storedID,
    storedTitle = lastTitle;
    storedID = lastID;
    SetOptions[$FrontEndSession, 
     DockedCells -> 
      Cell[BoxData[
        ToBoxes[Style[
          With[{dock = Options[$FrontEndSession, DockedCells]}, 
           Grid[{{Button[Style["\[CircleTimes]", 16], 
               SetOptions[$FrontEndSession, dock], 
               Appearance -> None], "New StackOverflow question: ", 
              Hyperlink[lastTitle, 
               "http://stackoverflow.com/questions/" <> 
                ToString[lastID]]}}, 
            Alignment -> {{Left, Left, Left}}, 
            ItemSize -> {{2, 14, Scaled[0.7]}}]], 
          FontFamily -> "Times"]]], "DockedCell", 
       Background -> Orange]]; EmitSound[Sound[SoundNote[]]]];, 60];

这篇关于使用Mathematica和StackOverflow API来关注Mathematica的新问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆