{"id":318,"date":"2009-06-17T02:20:09","date_gmt":"2009-06-17T09:20:09","guid":{"rendered":"https:\/\/actionsnippet.com\/?p=1566"},"modified":"2009-06-17T02:20:09","modified_gmt":"2009-06-17T09:20:09","slug":"random-negative-or-positive","status":"publish","type":"post","link":"https:\/\/actionsnippet.com\/?p=318","title":{"rendered":"Random Negative or Positive"},"content":{"rendered":"<pre class=\"brush: as3; title: ; notranslate\" title=\"\">\r\nfor (var i:int = 0; i&lt;10; i++){\r\n  \/\/ randomly set a variable to -1 or positive 1\r\n  trace(int(Math.random()*2) - 1 | 1);\r\n}\r\n\r\n\/* outputs something like this\r\n1\r\n1\r\n-1\r\n1\r\n-1\r\n-1\r\n1\r\n1\r\n-1\r\n-1\r\n*\/\r\n<\/pre>\n<p>The past few days I found myself using this one-liner a few times. Just a quick way to randomly get -1 or 1.<\/p>\n<p>I was brainstorming today and wrote a weird\/bad inline version of an <a href=\"https:\/\/actionsnippet.com\/?p=42\">old post<\/a>:<\/p>\n<p><code>var rand:Number = [-3, 2, 1, 1, 1, 0.5][int(Math.random() * 6)];<\/code><\/p>\n<p>I need to install a related posts plugin for WordPress &#8211; would be nice if this post were related to <a href=\"https:\/\/actionsnippet.com\/?p=809\">my old post about Tausworthe random seeds<\/a>.<\/p>\n<p>Been posting medium\/large snippets and snippets the relate to <a href=\"https:\/\/actionsnippet.com\/?page_id=1391\" target=\"blank\">QuickBox2D<\/a> &#8211; so today I figured I&#8217;d get back to basics&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>for (var i:int = 0; i&lt;10; i++){ \/\/ randomly set a variable to -1 or positive 1 trace(int(Math.random()*2) &#8211; 1 | 1); } \/* outputs something like this 1 1 -1 1 -1 -1 1 1 -1 -1 *\/ The past few days I found myself using this one-liner a few times. Just a quick [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[37,23],"tags":[3,14,4],"class_list":["post-318","post","type-post","status-publish","format-standard","hentry","category-one-liners","category-random","tag-actionscript","tag-as3","tag-flash"],"_links":{"self":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/318","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=318"}],"version-history":[{"count":0,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=\/wp\/v2\/posts\/318\/revisions"}],"wp:attachment":[{"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=318"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=318"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/actionsnippet.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=318"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}