小编duh*_*ime的帖子

在没有密码提示的情况下在Ubuntu上安装MySQL

如何编写脚本在Ubuntu上安装MySQL服务器?

sudo apt-get install mysql 将安装,但它也会要求在控制台中输入密码.

我如何以非交互方式执行此操作?也就是说,编写一个可以提供密码的脚本?

#!/bin/bash
sudo apt-get install mysql  # To install MySQL server

# How to write script for assigning password to MySQL root user
# End
Run Code Online (Sandbox Code Playgroud)

mysql bash ubuntu apt

299
推荐指数
3
解决办法
14万
查看次数

Python:Selenium Firefox Webdriver失败并显示错误:'无法加载配置文件... WARN addons.xpi ..."

我正在尝试运行以下Python代码以通过Selenium创建Firefox Webdriver窗口:

from selenium import webdriver
driver = webdriver.Firefox()
driver.get("http://www.google.com")
Run Code Online (Sandbox Code Playgroud)

虽然这段代码几周前工作正常,但它现在会产生以下预感信息:

 Traceback (most recent call last):
  File "test.py", line 2, in <module>
    driver = webdriver.Firefox()
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\webdriver.py", line 60, in __init__
    self.binary, timeout),
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\extension_connection.py", line 47, in __init__
    self.binary.launch_browser(self.profile)
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 61, in launch_browser
    self._wait_until_connectable()
  File "c:\python27\lib\site-packages\selenium\webdriver\firefox\firefox_binary.py", line 105, in _wait_until_connectable
    self.profile.path, self._get_firefox_output()))
selenium.common.exceptions.WebDriverException: Message: 'Can\'t load the profile. Profile Dir: c:\\users\\douglas\\appdata\\local\\temp\\tmpuf4ipq Firefox output: *** LOG addons.xpi: startup\r\n*** WARN addons.xpi: Ignoring missing add-on in C:\\Program Files\\CheckPoint\\ZAForceField\\WOW64\\TrustChecker\r\n*** WARN addons.xpi: …
Run Code Online (Sandbox Code Playgroud)

python firefox selenium xpi

27
推荐指数
1
解决办法
3万
查看次数

Chrome:CPU配置文件解析器正在修复n个丢失的示例

我正在使用Chrome的性能标签来研究网页的效果,我偶尔会收到如下警告:

DevTools:CPU配置文件解析器正在修复4个丢失的样本.

有谁知道这意味着什么?谷歌搜索此警告到目前为止没有返回任何结果......

google-chrome

17
推荐指数
1
解决办法
4269
查看次数

使用NLTK 3.0中的Wordnet从Synset中提取Word

前段时间,SO上的某个人询问如何使用NLTK的wordnet包装器检索给定synset的单词列表.以下是建议的回复之一:

for synset in wn.synsets('dog'):
    print synset.lemmas[0].name
Run Code Online (Sandbox Code Playgroud)

使用NLTK 3.0运行此代码会产生TypeError: 'instancemethod' object is not subscriptable.

我尝试了以前提出的每个解决方案(上面链接的页面上描述的每个解决方案),但每个都会抛出错误.因此,我想问:是否可以使用NLTK 3.0打印单词列表?我会感谢别人可以就这个问题提出的任何建议.

python nlp nltk wordnet

14
推荐指数
3
解决办法
2万
查看次数

Redux:从另一个动作创建者调用一个动作

我正在开发一个Redux应用程序,其中许多过滤器组件可以改变要执行的搜索的性质.每当其中一个过滤器组件的状态发生变化时,我想重新运行搜索操作.但是,我似乎无法正确地调用每个过滤器组件的搜索操作.

这是主要的搜索操作:

// actions/search.js
import fetch from 'isomorphic-fetch';
import config from '../../server/config';

export const receiveSearchResults = (results) => ({
  type: 'RECEIVE_SEARCH_RESULTS', results
})

export const searchRequestFailed = () => ({
  type: 'SEARCH_REQUEST_FAILED'
})

export const fetchSearchResults = () => {
  return (dispatch, getState) => {
    // Generate the query url
    const query = getSearchQuery();  // returns a url string
    return fetch(query)
      .then(response => response.json()
        .then(json => ({
          status: response.status,
          json
        })
      ))
      .then(({ status, json }) => {
        if (status …
Run Code Online (Sandbox Code Playgroud)

reactjs redux redux-thunk react-redux

12
推荐指数
1
解决办法
8065
查看次数

Chrome Webdriver通过Selenium发出错误消息:"允许web_page上下文需要为匹配项提供值"

我正在运行一个编译的Python脚本,该脚本使用Selenium来启动Chrome Webdriver会话,该会话访问一个站点并执行一些任务.该脚本的行为与我期望的一样,除了它在我第一次启动webdriver时向控制台输出"错误"消息.错误如下:

[2460:7268:1121/133303:ERROR:base_feature_provider.cc(122)] manifestTypes: Allowing web_page contexts requires supplying a value for matches.
Run Code Online (Sandbox Code Playgroud)

有谁知道这意味着什么?就像我上面说的那样,脚本看起来像我期望的那样,这让我想知道这条消息试图表明什么.谷歌搜索该短语会显示一大堆提及但未明确描述相同错误的code.google页面.我可以发布代码,但它太长(2000多行),我不确定哪些行与问题相关,因为我无法理解错误消息.我通常使用带有Selenium的Firefox浏览器,但我正在探索Chrome作为替代方案.无论如何,如果有人能帮我理解这个错误信息,我将非常感激.

python selenium google-chrome

10
推荐指数
1
解决办法
1900
查看次数

R:在ggplot2中使用free_x重新排序facet_wrapped x轴

我正在尝试reorder使用scales = free_x在ggplot2 中也使用的小面包裹的绘图,但是重新排序功能没有正确地重新排序x轴.这是我正在运行的:

library(ggplot2)

df <- read.table("speaking_distribution_by_play.txt",
                 header = F,
                 sep = "\t")

ggplot(df, aes(x=reorder(V2, V3), y=V3)) + 
  geom_bar(stat = "identity") +
  facet_wrap(~V1, ncol = 4, scales = "free_x") + 
  opts(title = "Distribution of Speakers in Shakespearean Drama") + 
  xlab("Speaking Role") + 
  ylab("Words Spoken") +
  opts(axis.text.x=theme_text(angle=90, hjust=1))
Run Code Online (Sandbox Code Playgroud)

在从此制表符分隔文件中读取的数据框上运行该代码会生成一个图,其中每个分面图的x轴仅部分排序.SO上的其他人提出了一个非常相似的问题,但唯一提出的解决方案是使用网格排列.因为我的数据集比那个问题中的数据集要大得多,所以这不会是一个非常迅速的操作,所以我想问:有没有办法重新排序每个刻面图的x轴,以便显示尺寸增加(或减少)的条形?我非常感谢其他人可以在这个问题上提供任何帮助.

plot r facet ggplot2

10
推荐指数
2
解决办法
2705
查看次数

估计两个词之间的音素相似性

我正在使用卡内基梅隆大学的发音词典检测Python中的押韵,并且想知道:我如何估计两个单词之间的音素相似度?换句话说,是否有一种算法可以识别"手"和"计划"比"手"和"薯条"更接近押韵的事实?

一些上下文:首先,我愿意说两个单词押韵,如果它们的主要重读音节和所有后续音节相同(如果你想在Python中复制,则为c06d):

def create_cmu_sound_dict():

    final_sound_dict = {}

    with open('resources/c06d/c06d') as cmu_dict:
        cmu_dict = cmu_dict.read().split("\n")
        for i in cmu_dict:
            i_s = i.split()
            if len(i_s) > 1:
                word = i_s[0]
                syllables = i_s[1:]

                final_sound = ""
                final_sound_switch = 0

                for j in syllables:
                    if "1" in j:
                        final_sound_switch = 1
                        final_sound += j
                    elif final_sound_switch == 1:
                        final_sound += j

            final_sound_dict[word.lower()] = final_sound

    return final_sound_dict
Run Code Online (Sandbox Code Playgroud)

如果我然后跑

print cmu_final_sound_dict["hands"]
print cmu_final_sound_dict["plans"]
Run Code Online (Sandbox Code Playgroud)

我可以看到手和计划听起来非常相似.我可以自己估计这种相似性,但我想我应该问:是否有复杂的算法可以将数学值与这种声音(或听觉)相似度联系起来?也就是说,可以使用哪些算法或包来对两个单词之间的音素相似度进行数学计算?我意识到这是一个很大的问题,但我非常感谢其他人可以就这个问题提出的建议.

python algorithm nlp linguistics phoneme

10
推荐指数
1
解决办法
1938
查看次数

Heroku:docker deploy 抛出未经授权:需要身份验证

我正在尝试使用以下步骤将一个简单的 Flask 服务器部署到 Heroku:

heroku login
heroku container:login

# create the app
heroku create myapp-name-2

# create the container with format:
# docker build -t registry.heroku.com/<app name>/<process type> .
docker build -t registry.heroku.com/myapp-name-2/web .

# push the image to the registry
docker push registry.heroku.com/myapp-name-2/web

# "release" the image
heroku container:release --app myapp-name-2 web

# open the app
heroku open --app myapp-name-2
Run Code Online (Sandbox Code Playgroud)

但是,该docker push步骤显示:

The push refers to repository [registry.heroku.com/myapp-name-2/web]
f60f7a4e2b2a: Preparing
3ff8a98d192e: Preparing
71476851914e: Preparing
013688a141bb: Preparing
f09460ef2908: …
Run Code Online (Sandbox Code Playgroud)

heroku docker

10
推荐指数
3
解决办法
2032
查看次数

在python中将二进制整数或字符串写入文件

我在Python中有一个字符串(也可能是整数),我想将它写入文件.它只包含1和0我想要将1和0的模式写入文件.我想直接编写二进制文件,因为我需要存储大量数据,但只需要存储某些值.当我只需要三个时,我认为没有必要占用每个值使用8位的空间.

例如.假设我要将二进制字符串写入"01100010"文件.如果我在文本编辑器中打开它会说b(01100010是b的ascii代码).不要混淆.我不想写ascii代码,这个例子只是为了表明我想直接将字节写入文件.


澄清:

我的字符串看起来像这样:

binary_string = "001011010110000010010"
Run Code Online (Sandbox Code Playgroud)

它不是由数字或字符的二进制代码组成.它包含仅与我的程序相关的数据.

python binary file-io file

9
推荐指数
2
解决办法
4万
查看次数