目前,我可以从覆盆子(raspbian)连接到我的家庭wifi,但当我尝试连接到iphone(4s)热点我不能.Iphone是WPA2 Personal,而我的家庭网络是WPA/WPA2 Personal.我怀疑我的配置有问题,但我真的找不到什么.这是相关部分/etc/wpa_supplicant/wpa_supplicant.conf.
network={
ssid="iPhone"
psk="pass"
proto=RSN
key_mgmt=WPA-PSK
pairwise=CCMP
auth_alg=OPEN
}
Run Code Online (Sandbox Code Playgroud)
这里参考我家网络的配置(工作)(在同一个文件中):
network={
ssid="wifi name"
psk="pass"
# Protocol type can be: RSN (for WP2) and WPA (for WPA1)
proto=WPA
# Key management type can be: WPA-PSK or WPA-EAP (Pre-Shared or Enterprise)
key_mgmt=WPA-PSK
# Pairwise can be CCMP or TKIP (for WPA2 or WPA1)
pairwise=TKIP
#Authorization option should be OPEN for both WPA1/WPA2 (in less commonly used are SHARED and LEAP)
auth_alg=OPEN
}
Run Code Online (Sandbox Code Playgroud) 我想使用HTTPoison库在Elixir中创建一个Github令牌,但我不知道如何发送HTTPoison参数.
使用时curl,它会是这样的
$ curl -i -u "ColdFreak" -H "X-GitHub-OTP: 123456" -d '{"scopes": ["repo", "user"], "note"
: "getting-started"}' https://api.github.com/authorizations
Run Code Online (Sandbox Code Playgroud)
当我使用HTTPoison库时,我无法弄清楚如何发布它.
url = "https://api.github.com/authorizations"
HTTPoison.post!(url, [scopes: ["repo", "user"], note: "getting-started"], %{"X-GitHub-OTP" => "12345"})
Run Code Online (Sandbox Code Playgroud)
然后它给出了类似的错误
** (ArgumentError) argument error
:erlang.iolist_to_binary([{"scopes", ["repo", "user"]}, {"note", "getting-started"}])
(hackney) src/hackney_client/hackney_request.erl:338: :hackney_request.handle_body/4
(hackney) src/hackney_client/hackney_request.erl:79: :hackney_request.perform/2
Run Code Online (Sandbox Code Playgroud)
有人能告诉我如何以正确的方式做到这一点
HTTPoison的文档在这里
我有一个应用程序,它完成后正常退出不应该重新启动.在此应用程序完成其业务之后,我想关闭实例(ec2).我正在考虑使用带有选项的systemd单元文件来执行此操作
Restart=on-failure
ExecStopPost=/path/to/script.sh
Run Code Online (Sandbox Code Playgroud)
应该运行的脚本ExecStopPost:
#!/usr/bin/env bash
# sleep 1; adding sleep didn't help
# this always comes out deactivating
service_status=$(systemctl is-failed app-importer)
# could also do the other way round and check for failed
if [ $service_status = "inactive" ]
then
echo "Service exited normally: $service_status . Shutting down..."
#shutdown -t 5
else
echo "Service did not exit normally - $service_status"
fi
exit 0
Run Code Online (Sandbox Code Playgroud)
问题是,当后停止运行时,我似乎无法检测服务是否正常结束,然后状态是deactivating,只有在我知道它是否进入failed状态之后.
假设我有这样的数据集:
5.9;0.645;0.12;2;0.075;32;44;0.99547;3.57;0.71;10.2;5
6;0.31;0.47;3.6;0.067;18;42;0.99549;3.39;0.66;11;6
Run Code Online (Sandbox Code Playgroud)
其中前11列表示特征(酸度,氯化物等),最后一列表示项目的评级(例如5或6)
因此训练数据集:
target = [x[11] for x in dataset]
train = [x[0:11] for x in dataset]
rf = RandomForestClassifier(n_estimators=120, n_jobs=-1)
rf.fit(train, target)
predictions = rf.predict_proba(testdataset)
print predictions[0]
Run Code Online (Sandbox Code Playgroud)
打印出类似的东西
[ 0. 0.01666667 0.98333333 0. 0. 0. ]
Run Code Online (Sandbox Code Playgroud)
现在,为什么它不输出单个分类,例如5或6等级?
文档说"输入样本的预测类概率被计算为森林中树木的平均预测类概率",我很难理解.
如果你使用
print rf.predict(testdataset[-1])
[ 6. 6. 6. 6. 6. 6. 6. 6. 6. 6. 6.]
Run Code Online (Sandbox Code Playgroud)
它打印的内容更像你期望的 - 至少它看起来像收视率 - 但我仍然不明白为什么每个功能都有预测而不考虑所有功能的单一预测?
我在ansible中有以下任务:
- file: "state=directory path=/servers/repo"
sudo: yes
name: "Create the base site directory."
Run Code Online (Sandbox Code Playgroud)
它应该以我的用户身份运行,但具有 root 权限。但是即使我的用户是 sudoer 它也失败了
Sorry, user sofiab is not allowed to execute '/bin/sh -c echo SUDO-SUCCESS-amlzcqzchzpjsgkllckjhjfednpjgevj; LANG=C LC_CTYPE=C /usr/bin/python /home/sofiab/.ansible/tmp/ansible-tmp-1409321488.66-202796192861545/file; rm -rf /home/sofiab/.ansible/tmp/ansible-tmp-1409321488.66-202796192861545/ >/dev/null 2>&1' as root
Run Code Online (Sandbox Code Playgroud)
当然,当我sudo -s在服务器中执行操作时,我拥有所有正确的权限,但不知何故与 ansible 无法正常工作。
知道为什么吗?
在 Tibshirani 的“统计学习元素”中,当比较最小二乘法/线性模型和 knn 时,说明了这两种情况:
场景 1:每个类中的训练数据是从具有不相关分量和不同均值的双变量高斯分布生成的。
场景 2:每个类中的训练数据来自 10 个低方差高斯分布的混合,每个均值本身按高斯分布。
这个想法是第一个更适合最小二乘/线性模型,第二个更适合 knn 类模型(那些与我理解的差异更大的模型,因为 knn 考虑了最近的点而不是所有点)。
在 R 中,我将如何模拟两种场景的数据?
最终目标是能够重现这两种情况,以证明线性模型能有效地解释第一种情况,而不是第二种情况。
谢谢!
假设我有2个案例类:
case class Basic(id: String, name) extends SomeBasicTrait
case class Info (age: Int, country: String, many other fields..) extends SomeInfoTrait
Run Code Online (Sandbox Code Playgroud)
并且想要创建一个包含这两个案例类中所有字段的案例类.这是一种可能的方式:
case class Full(bs: Basic, meta: Info) extends SomeBasicTrait with SomeInfoTrait {
val id = bs.id
val name = bs.name
val age = meta.age
val country = meta.country
// etc
}
Run Code Online (Sandbox Code Playgroud)
但它是很多样板代码.有什么方法可以避免这种情况吗?
我无法在Shapeless中找到实现这一目标的方法,但也许有......
[ 更新 ]
@jamborta的评论有帮助,基本上是这样的:
case class FullTwo(id: String, name: String, age:Int, country:String)
val b = Basic("myid", "byname")
val i = Info(12, "PT")
Generic[FullTwo].from(Generic[Basic].to(b) ++ Generic[Info].to(i))
Run Code Online (Sandbox Code Playgroud)
这个解决方案的问题在于它仍然需要在FullTwo …
我有一个文章表和一个类别表。我想为每个类别获取7篇文章。目前,我有这个功能,但是在大型表上速度很慢,所以这不是一个真正的解决方案:
SELECT id,
title,
categories_id,
body,
DATE_FORMAT(pubdate, "%d/%m/%y %H:%i") as pubdate
FROM articles AS t
WHERE (
SELECT COUNT(*)
FROM articles
WHERE t.categories_id = categories_id
AND id< t.id AND publish = 1
AND expires > '2008-12-14 18:38:02'
AND pubdate <= '2008-12-14 18:38:02'
) < 7
ORDER BY categories_id DESC
Run Code Online (Sandbox Code Playgroud)
使用explain,它向我展示了它正在做一个ALL&REF联接类型。选择类型为PRIMARY和DEPENDENT子查询。
有更好的解决方案吗?
如果我有字符串:
"O João foi almoçar :) ."
Run Code Online (Sandbox Code Playgroud)
我如何最好将它分成python中的单词列表,如下所示:
['O','João', 'foi', 'almoçar', ':)']
Run Code Online (Sandbox Code Playgroud)
?
谢谢 :)
苏菲亚
是否有任何方式可以使Warn功能起作用?
func Warn(s string, args ...interface{}) {
log.Printf("warn: "+s, args)
}
func main() {
Warn("%d apples, %s ", 10, "good") //it should output the same as below
log.Printf("%d apples, %s ", 10, "good")
}
Run Code Online (Sandbox Code Playgroud)
输出:
2009/11/10 23:00:00 warn: [10 %!d(string=good)] apples, %s(MISSING)
2009/11/10 23:00:00 10 apples, good
Run Code Online (Sandbox Code Playgroud)
我正在尝试做这项工作:http://play.golang.org/p/W62f2NGDUe
linux ×2
python ×2
ansible ×1
elixir ×1
emoticons ×1
go ×1
iphone ×1
mysql ×1
networking ×1
optimization ×1
r ×1
raspberry-pi ×1
scala ×1
scikit-learn ×1
shapeless ×1
split ×1
sql ×1
string ×1
systemd ×1
types ×1
ubuntu-12.04 ×1
wifi ×1