我需要使用C++检测操作系统名称,编译器名称和编译器版本,因为我需要更改每种情况的设置.
我怎样才能做到这一点?
假设您有一个具有以下结构的数据框:
df <- data.frame(a=c(1,2,3,4), b=c("job1;job2", "job1a", "job4;job5;job6", "job9;job10;job11"))
Run Code Online (Sandbox Code Playgroud)
列b是以分号分隔的列表(按行不平衡).理想的data.frame将是:
id,job,jobNum
1,job1,1
1,job2,2
...
3,job6,3
4,job9,1
4,job10,2
4,job11,3
Run Code Online (Sandbox Code Playgroud)
我有一个部分解决方案,需要将近2小时(170K行):
# Split the column by the semicolon. Results in a list.
df$allJobs <- strsplit(df$b, ";", fixed=TRUE)
# Function to reshape column that is a list as a data.frame
simpleStack <- function(data){
start <- as.data.frame.list(data)
names(start) <-c("id", "job")
return(start)
}
# pylr!
system.time(df2 <- ddply(df, .(id), simpleStack))
Run Code Online (Sandbox Code Playgroud)
它似乎是一个大小问题,因为如果我跑
system.time(df2 <- ddply(df[1:4000,c("id", "allJobs")], .(id), simpleStack))
Run Code Online (Sandbox Code Playgroud)
它只需要9秒钟.首先使用sapply(使用不同的函数)转换为一组data.frames很快,但所需的`rbind'需要更长的时间.
我所有的搜索都让人们提出了相反的问题,但如果用行返回和缩进保存,我有一个文件增长了近50%.
这有什么办法吗?
编辑我不是在谈论打开文件,而是保存文件.此代码为我重现了'bug':
var path = @"C:\test.xml";
System.IO.File.WriteAllText(path, "<root>\r\n\t<line></line>\r\n\t<line></line>\r\n</root>");
System.Xml.XmlDocument doc = new System.Xml.XmlDocument();
doc.PreserveWhitespace = false;
doc.Load(path);
doc.PreserveWhitespace = false; //just in case!
doc.Save(path);
Run Code Online (Sandbox Code Playgroud)
中间的断点显示doc.InnerXml是有效的<root><line></line><line></line></root>,正如预期的那样.但最后的内容test.xml是:
<root>
<line>
</line>
<line>
</line>
</root>
Run Code Online (Sandbox Code Playgroud) 我有一个应用程序,它处理一个非常大的文件并将数据发送到oracle数据库(使用Java 6,oracle 9).
在循环中,我使用a PreparedStatement ps并创建生成的所有SQL语句ps.addBatch().
我有一种情况BatchUpdateException bue是在某个地方抛出一个ps.executeBatch().此时,批处理停止执行.
我希望批处理执行继续,以便我可以检查方法中的失败更新processUpdateCounts(bue.getUpdateCounts()).
关于类BatchUpdateException的javadoc说:
在批量更新中的命令无法正确执行并且抛出BatchUpdateException之后,驱动程序可能会也可能不会继续处理批处理中的其余命令.
有没有办法强制执行继续,还是我需要改变我的程序,以便它将单独执行语句?
我正在寻找一个良好的PHP地理定位服务,所以当我启动我的应用程序时,我可以有类似的东西:
<?php
$service = new GeoLocService();
echo $service->getLat();
echo $service->getLng();
?>
Run Code Online (Sandbox Code Playgroud)
以纬度和逻辑值的形式检索用户的位置.
如何将iPhone设置为振动一次?
例如,当玩家失去生命或游戏结束时,iPhone应该振动.
有点混淆为什么这不起作用.我在Windows 7上使用Ruby 1.9.2和Rails 3.0.3.
尝试使用formtastic为post模型创建一个表单,然而,当我尝试渲染视图时,我继续为NilClass:Class获取未定义的方法`model_name'.
相关代码:
Demonly_controller.rb
class DemonlyController < ApplicationController
def index
@post = Post.all
end
end
Run Code Online (Sandbox Code Playgroud)
Posts_controller.rb
class PostsController < ApplicationController
end
Run Code Online (Sandbox Code Playgroud)
Post.rb
class Post < ActiveRecord::Base
attr_accessible :title, :post, :date, :time, :user, :visible, :comments
end
Run Code Online (Sandbox Code Playgroud)
Index.html.erb
<h1>Demonly</h1>
<% semantic_form_for @post do |f|%>
<%= f.errors %>
<%= f.inputs do %>
<%= f.input :title %>
<%= f.input :post %>
<%= f.input :date %>
<%= f.input :time %>
<%= f.input :user %>
<%= f.input :visible %> …Run Code Online (Sandbox Code Playgroud) 我想用一个链表像中描述的这个文件.但是,我没有在Web中找到任何Java实现.
如果没有上面提到的链表的java实现,我想,我会用的java.util.concurrent.ConcurrentLinkedQueue<E>.这是一个不错的选择(它不是一个真正的链表)?
如果它不是一个好的选择,有没有人知道Java中可靠的并发(线程安全)无等待(无锁)链接列表实现?
自从我使用Android的第一步以来,这个让我感到困惑.我不能在两列TableLayout中使两列完全相同.
这是一个例子:
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="wrap_content"
android:layout_width="fill_parent" >
<TableLayout
android:id="@+id/tablelayout"
android:layout_height="wrap_content"
android:layout_width="fill_parent"
android:paddingRight="2dip" >
<TableRow>
<TextView
style="@style/TextViewStandard"
android_layout_span="2"
android:layout_weight="1"
android:text="Bla" />
</TableRow>
<TableRow>
<TextView
style="@style/TextViewStandard"
android:layout_weight="1"
android:text="Name:" />
<EditText
style="@style/EditTextStandard"
android:id="@+id/et_name"
android:layout_weight="1" />
</TableRow>
<TableRow>
<TextView
style="@style/TextViewStandard"
android:layout_weight="1"
android:text="URL:" />
<EditText
style="@style/EditTextStandard"
android:id="@+id/et_url"
android:layout_weight="1" />
</TableRow>
<TableRow>
<Button
style="@style/ButtonStandard"
android:layout_column="0"
android:layout_marginTop="6dip"
android:onClick="onClickOk"
android:text="@android:string/ok" />
</TableRow>
</TableLayout>
</ScrollView>
Run Code Online (Sandbox Code Playgroud)
这是相应的样式定义:
<resources>
<style name="ButtonStandard" parent="@android:style/Widget.Button">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_width">fill_parent</item>
</style>
<style name="EditTextStandard" parent="@android:style/Widget.EditText">
<item name="android:layout_height">wrap_content</item>
<item name="android:layout_marginLeft">2dip</item>
<item name="android:layout_marginRight">2dip</item>
<item name="android:layout_marginTop">2dip</item>
<item name="android:layout_width">fill_parent</item>
</style> …Run Code Online (Sandbox Code Playgroud) 我需要在java中使用正则表达式操作从字符串中删除一个双字母.例如:PRINCEE - > PRINCE APPLE - > APLE
java ×3
.net ×1
android ×1
avfoundation ×1
c# ×1
c++ ×1
cocoa-touch ×1
concurrency ×1
dataframe ×1
formtastic ×1
geolocation ×1
ios ×1
jdbc ×1
layout ×1
linked-list ×1
oracle ×1
php ×1
plyr ×1
r ×1
regex ×1
resources ×1
ruby ×1
string ×1
vibration ×1
web-services ×1
xmldocument ×1