我可以使用Stackoverflow API检查哪些SO答录器没有睡眠吗? [英] Can I check with the Stackoverflow API which SO answerers are sleep-deprived?

查看:130
本文介绍了我可以使用Stackoverflow API检查哪些SO答录器没有睡眠吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

how-do-i-access-the- stackoverflow-api-from-mathematica 我概述了如何使用SO API来使Mathematica制作一些有趣的顶级回答者声誉图表.可以使用此API在答疑人的夜间习惯中提供一些侵犯隐私的见解吗?

In how-do-i-access-the-stackoverflow-api-from-mathematica I outlined how one could use the SO API to get Mathematica to make some interesting reputation graphs of top answerers. Could this API also be used to provide some privacy-invading insights in the answerers' nocturnal habits?

推荐答案

当然,例如,使用以下MMA8代码:

Certainly, for instance using this MMA8 code:

getActionDates[userID_Integer] :=
 Module[{total},
  total = 
   "total" /. 
    Import["http://api.stackoverflow.com/1.1/users/" <> 
      ToString[userID] <> "/timeline?pagesize=1&page=1", "JSON"];
  DateList[# + AbsoluteTime["January 1, 1970"]] & /@ Join @@
    Table[
     "creation_date" /. ("user_timelines" /. 
        Import["http://api.stackoverflow.com/1.1/users/" <> 
          ToString[userID] <> "/timeline?pagesize=100&page=" <> 
          ToString[p], "JSON"])
     , {p, Ceiling[total/100]}
     ]
  ]

makeWeekHistogram[userID_Integer] :=
 Module[{dates2Positions},
  dates2Positions = 
   ToExpression[
       DateString[#, {"{", "DayNameShort", "+", "Hour", "+", "Minute",
          "/60./.{Sun->0,Mon->24,Tue->2*24,Wed->3*24,Thu->4*24,Fri->5*\
24,Sat->6*24}}"}]] & /@ getActionDates[userID] // Flatten; 
  Histogram[dates2Positions, {1}, "Count", 
   GridLines -> {Table[24 i, {i, 1, 6}], None}, 
   BaseStyle -> {FontFamily -> "Arial-Bold", FontSize -> 16}, 
   FrameTicks -> {{Automatic, 
      None}, {{{12, "Sun"}, {24 + 12, "Mon"}, {2 24 + 12, 
        "Tue"}, {3 24 + 12, "Wed"}, {4 24 + 12, "Thu"}, {5 24 + 12, 
        "Fri"}, {6 24 + 12, "Sat"}}, None}}, 
   FrameLabel -> {"Day of week", "Number of actions", 
     First["display_name" /. ("users" /. 
         Import["http://api.stackoverflow.com/1.1/users/" <> 
           ToString[userID], "JSON"])], ""}, Frame -> True, 
   PlotRangePadding -> 0]
  ]

   makeDayHistogram[userID_Integer] :=
 Module[{dates2Positions},
  dates2Positions = 
   ToExpression[DateString[#, {"Hour", "+", "Minute", "/60."}]] & /@ 
     getActionDates[userID] // Flatten; 
  Histogram[dates2Positions, {1}, "Count", 
   FrameTicks -> {{Automatic, 
      None}, {Table[{i + 0.5, i}, {i, 0, 20, 5}], None}}, 
   BaseStyle -> {FontFamily -> "Arial-Bold", FontSize -> 16}, 
   FrameLabel -> {"Hour", "Number of actions", 
     First["display_name" /. ("users" /. 
         Import["http://api.stackoverflow.com/1.1/users/" <> 
           ToString[userID], "JSON"])], ""}, Frame -> True, 
   PlotRangePadding -> 0]
  ]

当然,我们只有服务器时间和日期,但是该模式应该可以告诉您有关本地化的信息,不是吗?尽管……巫师先生……你没有生命!

Of course, we only have server time and dates, but the pattern should tell something about localisation, not? Although... Mr.Wizard... you got no life!

makeWeekHistogram[353410]

编辑
向导要求的每小时直方图:

EDIT
Hourly histogram requested by Mr.Wizard:

这篇关于我可以使用Stackoverflow API检查哪些SO答录器没有睡眠吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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