V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  sadhen  ›  全部回复第 18 页 / 共 23 页
回复总数  445
1 ... 10  11  12  13  14  15  16  17  18  19 ... 23  
2018-10-11 10:12:32 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
@xcjx OK
2018-10-10 22:18:58 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
@xcjx @lnomve 请发邮件给我你们的收件地址和手机号哦,如果放弃的话,也麻烦告诉我哦

等到六个名额齐了,我们一起发货
2018-10-10 22:15:30 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
@wenning 不知道为啥,你进 Spam 了 [doge]
2018-10-10 17:42:04 +08:00
回复了 FaiChou 创建的主题 全球工单系统 stackoverflow 账号被限制提问, 如何恢复账号?
那个前端的圈子这么可怕 :(
2018-10-10 15:36:43 +08:00
回复了 FaiChou 创建的主题 全球工单系统 stackoverflow 账号被限制提问, 如何恢复账号?
可以回答问题么?回答问题可以赚 reputation 啊
2018-10-10 00:42:04 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
@xcjx @chocolatesir @lnomve @funky @wenning @magicsilence

请抽中的朋友提供一下收件信息:

1. 收件人
2. 收件地址
3. 手机号
2018-10-09 20:35:53 +08:00
回复了 sNullp 创建的主题 Irvine 定居 Irvine
羡慕有房的大🐿️
2018-10-09 20:33:58 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
2018-10-09 20:32:21 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
My_V2EX_Name 一共六个字母哦 @chocolatesir 就是你 AT 的那个
2018-10-09 20:19:07 +08:00
回复了 sadhen 创建的主题 程序员 用 Scala 在 V2EX 做抽奖活动
额 手贱发在问与答了
2018-10-09 20:07:56 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
恭喜 @xcjx @chocolatesir @lnomve @funky @wenning @magicsilence 中奖。请告诉我你们的联系方式。我的邮箱 MyV2EXNickname AT zoho.com

第二个附言写崩了 :(
2018-10-09 19:44:47 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
正式抽奖完整过程

➜ ~ amm
Loading...
Welcome to the Ammonite Repl 1.2.1
(Scala 2.12.6 Java 1.8.0_172)
If you like Ammonite, please support our development at www.patreon.com/lihaoyi
@ import $ivy.`com.lihaoyi::requests:0.1.4`
import $ivy.$

@ import $ivy.`org.json4s::json4s-jackson:3.5.2`
import $ivy.$

@ val url = "https://www.v2ex.com/api/replies/show.json?topic_id=493356"
url: String = "https://www.v2ex.com/api/replies/show.json?topic_id=493356"

@ val numberOfWinners = 6
numberOfWinners: Int = 6

@ val source = requests.get(url)
source: requests.Response = Response(
"https://www.v2ex.com/api/replies/show.json?topic_id=493356",
200,
"OK",
Map(
"etag" -> Buffer("W/\"02f2dce98bcae83800ccd1568488d6f583c9d72d\""),
"server" -> Buffer("Galaxy/3.9.8.1"),
"x-rate-limit-reset" -> Buffer("1539086400"),
"cache-control" -> Buffer("max-age=3600"),
"google" -> Buffer("XY"),
"date" -> Buffer("Tue, 09 Oct 2018 11:41:36 GMT"),
"x-rate-limit-limit" -> Buffer("120"),
"x-rate-limit-remaining" -> Buffer("118"),
"content-type" -> Buffer("application/json;charset=UTF-8"),
"transfer-encoding" -> Buffer("chunked"),
"connection" -> Buffer("keep-alive"),
"x-frame-options" -> Buffer("SAMEORIGIN"),
"vary" -> Buffer("Accept-Encoding"),
"strict-transport-security" -> Buffer("max-age=31536000"),
"content-encoding" -> Buffer("gzip")
...

@ import org.json4s.jackson.JsonMethods.parse
import org.json4s.jackson.JsonMethods.parse

@ val json = parse(source.text)
json: org.json4s.package.JValue = JArray(
List(
JObject(
List(
(
"member",
JObject(
List(
("username", JString("cye3s")),
("website", JString("")),
("github", JString("")),
("psn", JString("")),
("avatar_normal", JString("//cdn.v2ex.com/gravatar/041a96d84145b357e82a6e44628125f9?s=24&d=retro")),
("bio", JString("")),
("url", JString("https://www.v2ex.com/u/cye3s")),
("tagline", JString("")),
("twitter", JString("")),
("created", JInt(1409614320)),
("avatar_large", JString("//cdn.v2ex.com/gravatar/041a96d84145b357e82a6e44628125f9?s=24&d=retro")),
("avatar_mini", JString("//cdn.v2ex.com/gravatar/041a96d84145b357e82a6e44628125f9?s=24&d=retro")),
...

@ case class Profile(username: String, github: String)
defined class Profile

@ case class Member(member: Profile)
defined class Member

@ val members = json.extract[List[Member]].map(_.member.username).distinct
cmd9.sc:1: No org.json4s.Formats found. Try to bring an instance of org.json4s.Formats in scope or use the org.json4s.DefaultFormats.
val members = json.extract[List[Member]].map(_.member.username).distinct
^
Compilation Failed

@ implicit val formats = DefaultFormats
cmd9.sc:1: not found: value DefaultFormats
implicit val formats = DefaultFormats
^
Compilation Failed

@ import org.json4s._
import org.json4s._

@ import org.json4s.JsonDSL._
import org.json4s.JsonDSL._

@ implicit val formats = DefaultFormats
formats: DefaultFormats.type = org.json4s.DefaultFormats$@58647985

@ val members = json.extract[List[Member]].map(_.member.username).distinct
members: List[String] = List(
"cye3s",
"CoderHugo",
"zsh1995",
"densuc",
"sadhen",
"hepin1989",
"isnowify",
"chenpipguge",
"yorksonchang",
"WeberXie",
"0vels",
"duoweimi222",
"linghutf",
"nakedou",
"zhijiansha",
"Applenice",
"vecZro",
"billlee",
"someonedeng",
...

@ import scala.util.Random
import scala.util.Random

@ Random.shuffle(members).take(numberOfWinners )
res14: List[String] = List("xcjx", "chocolatesir", "lnomve", "funky", "wenning", "magicsilence")


很幸运,只在 REPL 里面粘贴错两次
2018-10-09 19:39:46 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
直播抽奖,首先参照一下之前 Flask 上面现有的 Python 代码在 Ammonite 中探索一下

```
@ repl.history.foreach(println)
import $ivy.`com.lihaoyi::requests:0.1.4`
import $ivy.`org.json4s::json4s-jackson:3.5.2`
val url = 'https://www.v2ex.com/api/replies/show.json?topic_id=490659'
val url = "https://www.v2ex.com/api/replies/show.json?topic_id=490659"
val numberOfWinners = 4
val source = requests.get(url)
import org.json4s.jackson.JsonMethods.parse
val json = parse(source.contents)
val json = parse(source.text)
json \\ "username"
json \ "username"
json \\ "username"
(json \\ "username").extract[List[String]]
import org.json4s._
import org.json4s.JsonDSL._
implicit val formats = DefaultFormats
(json \\ "username").extract[List[String]]
(json \\ "username").extract[List[(String, JString)]]
(json \\ "username")
(json \\ "username")head
(json \\ "username").head
json
(json \\ "username").head
(json \\ "username")
(json \\ "username").extract[List[JValue]]
(json \\ "username").extract[List]
(json \\ "username")
json
(json \\ "username")
(json \\ "username") \ "username"
json
json.head
json
case class Profile(username: String, github: String)
case class Member(member: Profile)
json.extract[List[Member]]
json.extract[List[Member]].map(_.member.name).distinct
json.extract[List[Member]].map(_.member.username).distinct
json.extract[List[Member]].map(_.member.username).distinct
val members = json.extract[List[Member]].map(_.member.username).distinct
import scala.util.Random
Random.shuffle(members)
Random.shuffle(members)
Random.shuffle(members).take(numberOfWinners )
help
:help
help
repl.help
repl.history
repl.history.head
repl.history.foreach(println)
repl.history.foreach(println)
```
2018-09-29 00:29:09 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
@tamlok 之前说翻译完,就抽点时间折腾 VNote。后来实在没有空,最后也只是捐赠了一杯奶茶 :doge:
2018-09-28 18:06:56 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
@Reznik

从单元测试开始,直接用。直接体验一下效率提升的感觉。

不要学,要用。
2018-09-28 17:49:41 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
@GoForce5500 此言差矣。即使排除 Spark,国内用 Scala 的公司还是有好多的。只不过很多项目是 Java 和 Scala 混血的,大家没有意识到而已。比如 腾讯的 Angel:

https://github.com/Angel-ML/angel
2018-09-28 15:30:41 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
@jqian 向大佬学习 博客很硬核 http://jqian.net/#myblog
2018-09-28 14:24:56 +08:00
回复了 Wang1990 创建的主题 问与答 有偿征集店名,采用发 5000 利是
黑科鸡排
2018-09-28 14:16:37 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
更新代码清单,没有见过比 @hepin1989 更勤快的

https://github.com/ReactivePlatform/Pragmatic-Scala/commits/sbt
2018-09-28 13:34:04 +08:00
回复了 sadhen 创建的主题 程序员 送出几本《Scala 实用指南》
编译期
1 ... 10  11  12  13  14  15  16  17  18  19 ... 23  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2039 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 21ms · UTC 01:07 · PVG 09:07 · LAX 18:07 · JFK 21:07
Developed with CodeLauncher
♥ Do have faith in what you're doing.