我有一个javascript文件,大约6000多行自己创建的代码.现在它有我的网站的不同部分的功能..现在我想问的是,我应该使用该大文件或将其分成各个部分的部分并在相应的部分中调用它.
(注意:此问题的所有答案均适用于版本10之前的Mathematica版本.对于版本10及更高版本,请参阅https://mathematica.stackexchange.com/questions/54486/how-to-access-new-colour- scheme-in-version-10和https://mathematica.stackexchange.com/questions/54629/what-are-the-standard-colors-for-plots-in-mathematica-10.)
在Mathematica中使用Plot或ListPlot命令时,会选择某些默认颜色.
出于某些报告中的一致性原因,我想将它们与PlotStyle选项一起使用.事实证明,我无法使用预定义的颜色名称重现默认颜色,尽管蓝色和紫色似乎在某种程度上接近.
因此我的问题是:
如何选择Mathematica在绘图中使用的标准颜色以及PlotStyle?
先感谢您.
belisarius和Sjoerd给出了很好的答案,我们可以从中得出结论
绘图[Sin [x],{x,0,2 Pi},PlotStyle - > ColorData [1,4]]
将导致以第四种标准颜色绘制的正弦值,一些漂亮的绿色.
我有一个在XAML中定义的动画(作为UserControl),它实际上每秒在两个图像之间切换:
<UserControl x:Class="KaleidoscopeApplication.Controls.RemoteAnimation"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Loaded="RemoteAnimation_Loaded"
Unloaded="RemoteAnimation_Unloaded">
<Grid Canvas.Left="500" Canvas.Top="84">
<Grid.Triggers>
<EventTrigger RoutedEvent="Grid.Loaded">
<BeginStoryboard>
<Storyboard x:Name="storyboard" RepeatBehavior="Forever">
<ObjectAnimationUsingKeyFrames Storyboard.TargetName="remote2" BeginTime="00:00:00" Storyboard.TargetProperty="(UIElement.Visibility)">
<DiscreteObjectKeyFrame KeyTime="0:0:1">
<DiscreteObjectKeyFrame.Value>
<Visibility>Collapsed</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
<DiscreteObjectKeyFrame KeyTime="0:0:2">
<DiscreteObjectKeyFrame.Value>
<Visibility>Visible</Visibility>
</DiscreteObjectKeyFrame.Value>
</DiscreteObjectKeyFrame>
</ObjectAnimationUsingKeyFrames>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
</Grid.Triggers>
<Image Name="remote1" Source="/Resources/Elements/Images/341.png"/>
<Image Name="remote2" Source="/Resources/Elements/Images/342.png"/>
</Grid>
</UserControl>
Run Code Online (Sandbox Code Playgroud)
它可以在窗口中使用:
<!-- Remote -->
<uControl:RemoteAnimation
x:Name="remoteAnimation"
Canvas.Left="316" Canvas.Top="156" Height="246" Width="121" />
Run Code Online (Sandbox Code Playgroud)
我的问题是,当包含动画的窗口关闭时,它会继续运行并导致泄漏.我无法通过带有storyboard.Stop()的RemoteAnimation_Unloaded()来停止动画......它不会做插孔.
我已经检查了这两个帖子,但它们不适用:
我能够进入卸载方法,但调用Stop()不会停止动画.根据我的理解,对于故事板调用Begin()可能是一个问题.isControlable参数存在重载.但是,由于动画完全在XAML中,我不确定如何影响它.
我正在Java应用程序中处理一些英文文本,我需要阻止它们.例如,从文字"amenities/amenity"我需要得到"amenit".
该功能如下:
String stemTerm(String term){
...
}
Run Code Online (Sandbox Code Playgroud)
我找到了Lucene分析仪,但它看起来太复杂了我需要的东西. http://lucene.apache.org/java/2_2_0/api/org/apache/lucene/analysis/PorterStemFilter.html
有没有办法用它来阻止单词而无需构建分析器?我不了解所有分析仪业务......
编辑:我实际上需要一个词干+词形还原.Lucene可以这样做吗?
我有一个模块:
module Room::Chair
def get_chair_type(user)
..
end
end
Run Code Online (Sandbox Code Playgroud)
然后,我有一个类方法' self.get_available_chair ',它在模块中调用' get_chair_type '方法Room::Chair
:
class Store < ActiveRecord::Base
include Room::Chair
def self.get_available_chair(user)
my_chair=get_chair_type(user) # error: undefined method 'get_chair_type'
end
end
Run Code Online (Sandbox Code Playgroud)
我有include Room::Chair
,但我得到错误undefined方法'get_chair_type(用户)'为什么?
我正在使用django开发一个项目.我正在使用git来控制它的版本.
我想使用一些可重复使用的django应用程序,例如django-mailer用于该项目.我打算分叉github repo并将其克隆到项目文件夹.但这将在另一个内部带来一个git repo.我也不确定是否需要fork.
你如何处理类似的情况?任何最佳做法?
我有以下场景:
我的主应用程序(APP1)启动一个进程(SERVER1).SERVER1通过命名管道承载WCF服务.我想连接到这个服务(从APP1),但有时它还没有准备好.
我创建了ChannelFactory,打开它并让它生成一个客户端.如果我现在在生成的客户端上调用一个方法,我会收到一个excpetion whitch告诉我没有找到Enpoint:
var factory = new ChannelFactory<T>(new NetNamedPipeBinding(), new EndpointAddress("net.pipe//localhost/myservice");
factory.Open()
var Client = factory.CreateChannel();
Client.Foo();
Run Code Online (Sandbox Code Playgroud)
如果我在拨打电话前等一下,一切都很好;
var Client = factory.CreateChannel();
Thread.Sleep(2000);
Client.Foo();
Run Code Online (Sandbox Code Playgroud)
如何确保服务准备就绪而无需等待一段随机时间?
我有一个组合框,根据另一个组合框的选择填充其值.我已经看到了基于选择更改底层存储中的参数的示例,但我想要实现的是根据第一个组合的选择更改第二个组合的存储本身.这是我的代码,但它不起作用.有人可以帮忙吗?
{
xtype: 'combo',
id: 'leads_filter_by',
width: 100,
mode: 'local',
store: ['Status','Source'],
//typeAhead: true,
triggerAction: 'all',
selectOnFocus:true,
typeAhead: false,
editable: false,
value:'Status',
listeners:{
'select': function(combo,value,index){
var filter_to_select = Ext.getCmp('cmbLeadsFilter');
var container = filter_to_select.container;
if (index == 0){
filter_to_select.store=leadStatusStore;
filter_to_select.displayField='leadStatusName';
filter_to_select.valueField='leadStatusId';
} else if(index==1) {
filter_to_select.store=leadSourceStore;
filter_to_select.displayField='leadSourceName';
filter_to_select.valueField='leadSourceId';
}
}
}
},
{
xtype: 'combo',
id: 'cmbLeadsFilter',
width:100,
store: leadStatusStore,
displayField: 'leadStatusName',
valueField: 'leadStatusId',
mode: 'local',
triggerAction: 'all',
selectOnFocus:true,
typeAhead: false,
editable: false
},
Run Code Online (Sandbox Code Playgroud) 我可以访问.com区域文件.区域文件是一个文本文件,其中包含域名列表及其名称服务器.它遵循以下格式:
mydomain NS ns.mynameserver.com.
mydomain NS ns2.mynameserver.com.
anotherdomain NS nameservers.com.
notinalphadomain NS ns.example.com.
notinalphadomain NS ns1.example.com.
notinalphadomain NS ns2.example.com.
Run Code Online (Sandbox Code Playgroud)
如您所见,每个域可以有多行(当有多个名称服务器时),并且文件不是 按字母顺序排列的.这些文件大小约为7GB.
我正在尝试获取上一个文件和新文件,并将它们进行比较以查找:
由于7GB太大而无法将整个文件加载到内存中,显然我需要在流中读取.我目前认为最好的方法是对两个文件进行多次传递.字母表中每个字母的一次传递,加载第一次传递中以'a'开头的所有域.一旦我从旧文件和新文件中获得了所有"a"域,我就可以在内存中进行非常简单的比较来查找更改.
问题是,即使通过char读取char,并按照我能够想到的优化,每次传递文件大约需要200-300秒,收集当前传递字母的所有域.因此,我认为在当前状态下,我正在查看大约一个小时来处理文件,甚至没有将更改存储在数据库中(这将花费更多时间).这是在双四核xeon服务器上,因此对它投入更多的马力对我来说不是一个选择.这个时间可能不是一个交易破坏者,但我希望有人对如何加快速度提出一些明智的想法......不可否认,我还没有尝试过async IO,这是我的下一步.
提前感谢任何想法!
天儿真好!
我有一个关于friend
在C++中使用的问题.考虑以下代码:
#include <ostream>
struct F {
};
struct N {
friend std::ostream& operator<< (std::ostream&, const N&);
friend std::ostream& operator<< (std::ostream&, const F&);
};
void foo(std::ostream &out) {
F bar;
out << bar;
}
Run Code Online (Sandbox Code Playgroud)
我的理解总是,这与函数可以访问类的私有部分的附加属性friend
类似.在这个假设下,代码应该编译,因为有一个需要a 和a(const).static
friend
operator<<
ostream&
F&
似乎g ++ 4.0对此有共同的看法,因为它接受了这个代码.然而,更新的g ++ 4.5(.2)拒绝带有消息的代码:
ns.cc: In function 'void foo(std::ostream&)':
ns.cc:14:10: error: no match for 'operator<<' in 'out << bar'
Run Code Online (Sandbox Code Playgroud)
是g ++ 4.5错了还是我(和g ++ 4.0)错了?
(将朋友声明移入F
课堂的解决方案没有帮助,因为operator<<
需要访问私人部分N
.)
此致,斯特凡