<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<oembed>
  <author_name>ainame</author_name>
  <author_url>https://blog.hatena.ne.jp/ainame/</author_url>
  <blog_title>ainameの日記</blog_title>
  <blog_url>https://ainame.hateblo.jp/</blog_url>
  <categories>
  </categories>
  <description>サービスの機能を考える時などに、「ユーザのデータをいい感じにランダムに選んで、こちらが自動的にまとめて表示してあげたい」みたいな会話がされるけど、この場合のランダムというのは純粋なランダムではない場合が多い。 例えば、CGM系のサービスでユーザの投稿をランダムに5件、抜き出してまとめて表示するというような機能を考えた時には、実際に本当にランダムに取得してしまうと、よくない結果が得られてしまう。 純粋なランダム選択をRuby(Rails)で書くなら、こう。 posts = Post.where(user_id: user_id).all random_posts = post.sample(5)…</description>
  <height>190</height>
  <html>&lt;iframe src=&quot;https://hatenablog-parts.com/embed?url=https%3A%2F%2Fainame.hateblo.jp%2Fentry%2F2015%2F03%2F25%2F192052&quot; title=&quot;ユーザーのデータをランダムに選んでまとめる機能について考える - ainameの日記&quot; class=&quot;embed-card embed-blogcard&quot; scrolling=&quot;no&quot; frameborder=&quot;0&quot; style=&quot;display: block; width: 100%; height: 190px; max-width: 500px; margin: 10px 0px;&quot;&gt;&lt;/iframe&gt;</html>
  <image_url>http://cdn-ak.f.st-hatena.com/images/fotolife/a/ainame/20150325/20150325184346.png</image_url>
  <provider_name>Hatena Blog</provider_name>
  <provider_url>https://hatena.blog</provider_url>
  <published>2015-03-25 19:20:52</published>
  <title>ユーザーのデータをランダムに選んでまとめる機能について考える</title>
  <type>rich</type>
  <url>https://ainame.hateblo.jp/entry/2015/03/25/192052</url>
  <version>1.0</version>
  <width>100%</width>
</oembed>
