{"action":"created","issue":{"url":"https://api.github.com/repos/3dgen/cppwasm-book/issues/4","repository_url":"https://api.github.com/repos/3dgen/cppwasm-book","labels_url":"https://api.github.com/repos/3dgen/cppwasm-book/issues/4/labels{/name}","comments_url":"https://api.github.com/repos/3dgen/cppwasm-book/issues/4/comments","events_url":"https://api.github.com/repos/3dgen/cppwasm-book/issues/4/events","html_url":"https://github.com/3dgen/cppwasm-book/issues/4","id":389031537,"node_id":"MDU6SXNzdWUzODkwMzE1Mzc=","number":4,"title":"抽奖送3本<WebAssembly标准入门>图书","user":{"login":"chai2010","id":2295542,"node_id":"MDQ6VXNlcjIyOTU1NDI=","avatar_url":"https://avatars1.githubusercontent.com/u/2295542?v=4","gravatar_id":"","url":"https://api.github.com/users/chai2010","html_url":"https://github.com/chai2010","followers_url":"https://api.github.com/users/chai2010/followers","following_url":"https://api.github.com/users/chai2010/following{/other_user}","gists_url":"https://api.github.com/users/chai2010/gists{/gist_id}","starred_url":"https://api.github.com/users/chai2010/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chai2010/subscriptions","organizations_url":"https://api.github.com/users/chai2010/orgs","repos_url":"https://api.github.com/users/chai2010/repos","events_url":"https://api.github.com/users/chai2010/events{/privacy}","received_events_url":"https://api.github.com/users/chai2010/received_events","type":"User","site_admin":false},"labels":[{"id":1068241651,"node_id":"MDU6TGFiZWwxMDY4MjQxNjUx","url":"https://api.github.com/repos/3dgen/cppwasm-book/labels/bug","name":"bug","color":"d73a4a","default":true}],"state":"open","locked":false,"assignee":{"login":"chai2010","id":2295542,"node_id":"MDQ6VXNlcjIyOTU1NDI=","avatar_url":"https://avatars1.githubusercontent.com/u/2295542?v=4","gravatar_id":"","url":"https://api.github.com/users/chai2010","html_url":"https://github.com/chai2010","followers_url":"https://api.github.com/users/chai2010/followers","following_url":"https://api.github.com/users/chai2010/following{/other_user}","gists_url":"https://api.github.com/users/chai2010/gists{/gist_id}","starred_url":"https://api.github.com/users/chai2010/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chai2010/subscriptions","organizations_url":"https://api.github.com/users/chai2010/orgs","repos_url":"https://api.github.com/users/chai2010/repos","events_url":"https://api.github.com/users/chai2010/events{/privacy}","received_events_url":"https://api.github.com/users/chai2010/received_events","type":"User","site_admin":false},"assignees":[{"login":"chai2010","id":2295542,"node_id":"MDQ6VXNlcjIyOTU1NDI=","avatar_url":"https://avatars1.githubusercontent.com/u/2295542?v=4","gravatar_id":"","url":"https://api.github.com/users/chai2010","html_url":"https://github.com/chai2010","followers_url":"https://api.github.com/users/chai2010/followers","following_url":"https://api.github.com/users/chai2010/following{/other_user}","gists_url":"https://api.github.com/users/chai2010/gists{/gist_id}","starred_url":"https://api.github.com/users/chai2010/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chai2010/subscriptions","organizations_url":"https://api.github.com/users/chai2010/orgs","repos_url":"https://api.github.com/users/chai2010/repos","events_url":"https://api.github.com/users/chai2010/events{/privacy}","received_events_url":"https://api.github.com/users/chai2010/received_events","type":"User","site_admin":false}],"milestone":null,"comments":12,"created_at":"2018-12-09T15:04:10Z","updated_at":"2018-12-10T05:53:27Z","closed_at":null,"author_association":"COLLABORATOR","body":"## 抽奖链接\r\n\r\n[https://github.com/3dgen/cppwasm-book/issues/4](https://github.com/3dgen/cppwasm-book/issues/4)\r\n\r\n----\r\n\r\n## <WebAssembly标准入门>相关链接：\r\n\r\n- Github: https://github.com/chai2010/awesome-wasm-zh/blob/master/webassembly-primer.md\r\n- 异步：[https://www.epubit.com/book/detail/40619](https://www.epubit.com/book/detail/40619)\r\n- 豆瓣：[https://book.douban.com/subject/30396640/](https://book.douban.com/subject/30396640/)\r\n- 京东：[https://item.jd.com/12499372.html](https://item.jd.com/12499372.html)\r\n\r\n----\r\n\r\n## 公平公正的抽奖规则\r\n\r\n抽奖规则的设计原则：\r\n\r\n- 组织方和参与者均有参与感\r\n- 抽奖的结果可重现，但是开奖之前无法预支结果\r\n\r\n收集参与抽奖的人\r\n\r\n- 必须有github账号，并在这个issue留言参与抽奖\r\n- github账号必须2018年之前申请的\r\n- 只接受大陆普通快递可达地区\r\n\r\n抽奖的流程\r\n\r\n1. 开始前，大家可以验证规则是否有缺陷，有任何问题都可以讨论\r\n1. 我在抽奖正式开始时(可以提前参与)，会准备一个秘密的字符串作为种子，然后先公布种子字符串的MD5，同时公布截止的规则(可以是ID达到一个数量, 或者是设置一个截止时间里程碑)\r\n1. 参与抽象的同学回复一个幸运字符串(`[0-9a-zA-Z-_]`等字符组成，1-32个字符)，也可以用自己的账号(如果用户如果担心泄密，也可以公布MD5)\r\n1. 开奖前我公布作为种子的秘密字符串，大家可以验证MD5，以防止我作弊\r\n1. 开奖前，参与者如果是提供MD5的也需要公布自己的幸运字符串，大家也去验证\r\n1. 每个ID和秘密的种子字符串各生成一个对应的crc32数字，最后把数字加起来对人数取模就是中奖号\r\n1. 每个ID作为utf8字符串排序，排序后的位置就是每个ID的抽奖号码\r\n1. 在开奖后和结果公布之前，会锁定这个issue，之后会再重新打开\r\n1. 抽完一个之后删除中奖ID，继续上述流程\r\n1. 任何人可以验证结果\r\n\r\n补充点：\r\n\r\n- 有任何疑问请加入 QQ群 (726475047) 讨论\r\n- 如果用户以MD5公布的幸运号，那么在抽奖截止后要公布真实的幸运号，否则作废\r\n- 如果担心MD5不够安全，可以加盐，比如  `abc:sdfsd` 生成的MD5, abc是幸运号，冒号后面是salt\r\n- 每个账号如果回复多个幸运字符串，以开奖前的最后一个为准\r\n- chai2010和ending不参与\r\n\r\n----\r\n\r\n## 抽奖的代码(Go语言实现)\r\n\r\n下面是抽奖算法的例子，种子字符串是wasm，2各参与者：\r\n\r\n```go\r\n// Copyright 2018 chaishushan@gmail.com. All rights reserved.\r\n// Use of this source code is governed by a BSD-style\r\n// license that can be found in the LICENSE file.\r\n\r\npackage main\r\n\r\nimport (\r\n\t\"fmt\"\r\n\t\"hash/crc32\"\r\n\t\"sort\"\r\n)\r\n\r\nfunc main() {\r\n\tluckyStar := MakeLuckyStar(\"wasm\", map[string]string{\r\n\t\t\"chai2010\": \"chai2010\",\r\n\t\t\"ending\":   \"ending\",\r\n\t})\r\n\r\n\tfmt.Println(luckyStar)\r\n\t// output: ending\r\n}\r\n\r\nfunc MakeLuckyStar(seed string, luckyTokens map[string]string) string {\r\n\tvar (\r\n\t\tcrc32Sum   = uint64(crc32.ChecksumIEEE([]byte(seed)))\r\n\t\tsortedKeys = make([]string, 0, len(luckyTokens))\r\n\t)\r\n\r\n\tfor id, tok := range luckyTokens {\r\n\t\tcrc32Sum += uint64(crc32.ChecksumIEEE([]byte(tok)))\r\n\t\tsortedKeys = append(sortedKeys, id)\r\n\t}\r\n\tsort.Strings(sortedKeys)\r\n\r\n\tidx := int(crc32Sum) % len(luckyTokens)\r\n\treturn sortedKeys[idx]\r\n}\r\n```\r\n\r\nhttps://play.golang.org/p/mox2zhbde49\r\n"},"comment":{"url":"https://api.github.com/repos/3dgen/cppwasm-book/issues/comments/445696065","html_url":"https://github.com/3dgen/cppwasm-book/issues/4#issuecomment-445696065","issue_url":"https://api.github.com/repos/3dgen/cppwasm-book/issues/4","id":445696065,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0NTY5NjA2NQ==","user":{"login":"vfan","id":1477088,"node_id":"MDQ6VXNlcjE0NzcwODg=","avatar_url":"https://avatars1.githubusercontent.com/u/1477088?v=4","gravatar_id":"","url":"https://api.github.com/users/vfan","html_url":"https://github.com/vfan","followers_url":"https://api.github.com/users/vfan/followers","following_url":"https://api.github.com/users/vfan/following{/other_user}","gists_url":"https://api.github.com/users/vfan/gists{/gist_id}","starred_url":"https://api.github.com/users/vfan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vfan/subscriptions","organizations_url":"https://api.github.com/users/vfan/orgs","repos_url":"https://api.github.com/users/vfan/repos","events_url":"https://api.github.com/users/vfan/events{/privacy}","received_events_url":"https://api.github.com/users/vfan/received_events","type":"User","site_admin":false},"created_at":"2018-12-10T05:53:27Z","updated_at":"2018-12-10T05:53:27Z","author_association":"NONE","body":"jscoder"}}
{"actor":{"display_login":"vfan"}}