我想迭代一个文件列表,而不关心文件名可能包含哪些字符,所以我使用一个由空字符分隔的列表.代码将更好地解释事情.
# Set IFS to the null character to hopefully change the for..in
# delimiter from the space character (sadly does not appear to work).
IFS=$'\0'
# Get null delimited list of files
filelist="`find /some/path -type f -print0`"
# Iterate through list of files
for file in $filelist ; do
# Arbitrary operations on $file here
done
Run Code Online (Sandbox Code Playgroud)
从文件读取时,以下代码有效,但我需要从包含文本的变量中读取.
while read -d $'\0' line ; do
# Code here
done < /path/to/inputfile
Run Code Online (Sandbox Code Playgroud) 操作系统名称:"linux"版本:"2.6.32-27-generic"arch:"i386"系列:"unix"
Apache Maven 2.2.1(r801777; 2009-08-06 12:16:01-0700)
Java版本:1.6.0_20
我试图在ubuntu中使用maven与maven相关联.如果我移动maven下载到我的$ JAVA_HOME/jre/lib/ext /文件夹中的"mysql-connector-java-5.1.14.jar"文件,那么当我运行jar时一切都很好.
我想我应该只能在pom.xml文件中指定依赖项,maven应该自动设置依赖项jar的类路径.这是不正确的?
我的pom.xml文件如下所示:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.ion.common</groupId>
<artifactId>TestPreparation</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<name>TestPrep</name>
<url>http://maven.apache.org</url>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifest>
<addClasspath>true</addClasspath>
<mainClass>com.ion.common.App</mainClass>
</manifest>
</archive>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- JUnit testing dependency -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<!-- MySQL database driver -->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.14</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
Run Code Online (Sandbox Code Playgroud)
命令"mvn package"构建它没有任何问题,我可以运行它,但是当应用程序尝试访问数据库时,会出现以下错误:
java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
at java.net.URLClassLoader$1.run(URLClassLoader.java:217)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:205)
at …Run Code Online (Sandbox Code Playgroud) 我编写了自动脚本来测试非常重的ajax的Web应用程序.例如,Saving...在保存设置时会显示带有文本" " 的模态对话框,而灯箱会使页面的其余部分灰显.
我的测试脚本试图在消息消失之前单击测试中的下一个链接.它几乎总是在驱动Firefox时有效,但在驱动Chrome时会显示以下错误:
Exception in thread "main" org.openqa.selenium.WebDriverException: Element is not clickable at point (99.5, 118.5). Other element would receive the click: <div class="dijitDialogUnderlay _underlay" dojoattachpoint="node" id="lfn10Dijit_freedom_widget_common_environment_Dialog_8_underlay" style="width: 1034px; height: 1025px; "></div> (WARNING: The server did not provide any stacktrace information)
Run Code Online (Sandbox Code Playgroud)
发生这种情况是因为灯箱遮挡了我想要点击的元素.我想在尝试点击链接之前等待灯箱消失.
检查灯箱不再存在不是一种有效的解决方法,因为有时会有多个级别的模态对话框和灯箱,并且没有简单的方法来区分它们.
在Selenium中是否有办法检测元素是否可点击(没有其他元素遮盖它)?尝试/捕获将是一种解决方法,但我更愿意做一个正确的检查,如果可能的话.
我正在设计一个Web应用程序,一般风格涉及深色背景上的白色文本.
此样式包括使用自定义(暗)图像作为用户名和密码字段,并带有白色文本.
如果用户使用谷歌浏览器登录并选择保存表单的登录详细信息,则在下次访问时,用户名和密码字段将显示为带有白色文本的淡黄色,使其几乎无法读取.这看起来很糟糕.
我将如何重写此样式,防止Google Chrome更改已保存的用户名和密码字段的背景.
<style type="text/css">
input {
border: none;
background: url('darkinput.png');
color: #fff;
}
</style>
<input type="text" name="email" id="text" />
<input type="password" name="password" id="text" />
Run Code Online (Sandbox Code Playgroud)
编辑:当前(google-chrome v11.0.696.57)用户代理样式表包含!重要覆盖以设置以下两项:
input:-webkit-autofill{
background-color: rgb(250, 255, 189) !important;
background-image: none !important;
}
Run Code Online (Sandbox Code Playgroud)
在下面的网址上有一个问题报告,我鼓励所有阅读此内容的人投票支持:
pwd是"目前的工作目录".这是情况.
pwd: /path/to/pwd/
git repository: /repo/path/.git/
Run Code Online (Sandbox Code Playgroud)
我想从源头做一个git pull,但不改变我当前的目录.
为了澄清一点,如果我不够清楚,这是我想要的结果,但我想用一个命令而不是必须更改目录:
$ cd /repo/path
$ git pull origin master
$ cd -
Run Code Online (Sandbox Code Playgroud) 有没有办法对mysql的'show tables'命令返回的表列表进行排序?
mysql> show tables;
Run Code Online (Sandbox Code Playgroud)
我想按表名字母顺序排序.
编辑:
正如其中一个答案所指出的,它们已经按字母顺序排列.但是,A!= a.有没有办法忽略排序中的案例?
好吧,我对这些东西感到非常困惑,所以真正的描述性答案会受到赞赏,特别是如果它们使整个装置不那么神奇且更具可预测性.
我正在尝试使用nfs安装我的Drobo-FS NAS以获得比使用cif更好的性能.
drobo正在运行一些精简的linux发行版.
在客户端计算机上的/ etc/fstab内部(Ubuntu,IP:192.168.1.150)
# Mount Drobo
192.168.1.100:/mnt/DroboFS/Shares/public /media/drobonfs nfs rw,soft,proto=tcp,users 0 0
Run Code Online (Sandbox Code Playgroud)
我已经在drobo上安装了unssd并通过ssh访问.这是服务器计算机上的导出文件(Drobo-FS,IP 192.168.1.100):
# Allow access for client machine
/mnt/DroboFS/Shares 192.168.1.150(rw,no_root_squash)
Run Code Online (Sandbox Code Playgroud)
挂载工作正常,但挂载的文件全部由root拥有,大多数文件权限设置为744.客户端上挂载中显示的文件权限与服务器上的实际权限相匹配.例如:
client$ sudo chmod 123 /media/drobonfs/somefile
client$ ls -l /media/drobonfs/somefile
---x-w--wx 1 root root 0 2012-01-04 14:15 /media/drobonfs/somefile
drobo$ ls -l /mnt/DroboFS/Shares/public/somefile
---x-w--wx 1 root root 0 Jan 4 14:15 /mnt/DroboFS/Shares/public/somefile
Run Code Online (Sandbox Code Playgroud)
在每个命令前写sudo是一个拖累,我想了解发生了什么,所以如何将所有者/组设置为我的帐户而不是根目录,将其挂载到客户端计算机上?
这非常类似于另一个被关闭的问题,而不是一个真正的问题.我试图编辑它以使其有效重新开放,但被告知我最好不要问一个新问题.
我正在开发android并需要在sqlite数据库中存储datetime值来跟踪将生成通知的重复事件.我还需要能够根据时间范围查询数据库.
在SQLite的文档指出它不支持特定的日期类型但日期可以使用文本,REAL,或整型表示:
TEXT为ISO8601字符串("YYYY-MM-DD HH:MM:SS.SSS").
真实如朱利安日数,根据公历4714年11月24日格林威治中午以来的天数.
INTEGER as Unix Time,自1970-01-01 00:00:00 UTC以来的秒数.
最初的优点似乎是:
这听起来不错吗?使用INTEGER作为日期时间会使查询时间范围明显快于使用TEXT时的速度吗?还有什么我还没考虑过吗?
鉴于我的用例,哪些解决方案最好?
我正在尝试计算一行中正则表达式匹配的数量,我需要在 vim 函数中使用结果。例如,计算左大括号的数量。
function! numberOfMatchesExample(lnum)
let line_text = getline(a:lnum)
" This next line is wrong and is the part I'm looking for help with
let match_list = matchlist(line_text, '{')
return len(match_list)
endfunction
Run Code Online (Sandbox Code Playgroud)
所以我想在 vim 函数中找到一种方法来将一行的正则表达式匹配数捕获到一个变量中。
有很多示例说明如何执行此操作并在状态栏上显示结果,请参阅
:h count-items,但我需要将数字捕获到变量中以便在函数中使用。
我遇到的主要问题是从表中提取数据,但任何其他一般提示也将受到欢迎。我正在处理的表大约有 25 列和不同数量的行(从 5 到 50 之间)。
目前我正在抓取表格并将其转换为数组:
require "watir-webdriver"
b = Watir::Browser.new :chrome
b.goto "http://someurl"
# The following operation takes way too long
table = b.table(:index, 1).to_a
# The rest is fast enough
table.each do |row|
# Code for pulling data from about 15 of the columns goes here
# ...
end
b.close
Run Code Online (Sandbox Code Playgroud)
table = b.table(:index, 5).to_a当表有20行时,该操作需要一分多钟。看起来将 20 X 25 表的单元格放入数组应该非常快。我需要对 80 多个表执行此操作,因此最终需要 1-2 小时才能运行。为什么需要这么长时间以及如何提高速度?
我尝试过迭代表行,而无需先转换为数组,但性能没有任何改进:
b.table(:index, 1).rows.each do |row|
# ...
Run Code Online (Sandbox Code Playgroud)
使用 Windows 7 和 Ubuntu 的结果相同。我也尝试过使用 …
我正在使用delphi编写的Web应用程序,并且无法从值数组中获取值.表单看起来类似于:
<form method="post">
<input type="hidden" name="keyword[]" value="1"/>
<input type="hidden" name="keyword[]" value="2"/>
<input type="hidden" name="keyword[]" value="3"/>
<input type="submit" value="submit"/>
</form>
Run Code Online (Sandbox Code Playgroud)
如果这是一个具有唯一名称的单个输入,我可以使用以下方法提取数据:
var cKeyword : String ;
cKeyword := Request.ContentFields.Values['keyword'] ;
Run Code Online (Sandbox Code Playgroud)
我正在寻找这样的东西:
var aKeywords : Array of String ;
aKeywords := Request.ContentFields.Values['keyword[]'] ;
Run Code Online (Sandbox Code Playgroud)
在PHP中你可以使用$aKeywords = $_POST['keyword'],我希望有一种方法可以在delphi中执行此操作.
提前感谢您提供的任何帮助.