在ggplot中做facet我经常喜欢使用百分比而不是计数.
例如
test1 <- sample(letters[1:2], 100, replace=T)
test2 <- sample(letters[3:8], 100, replace=T)
test <- data.frame(cbind(test1,test2))
ggplot(test, aes(test2))+geom_bar()+facet_grid(~test1)
Run Code Online (Sandbox Code Playgroud)
这很容易,但如果N在方面A上与方面B不同,那么我认为比较百分比会更好,这样每个方面的总和达到100%.
你会怎么做到这一点?
希望我的问题有道理.
真诚.
我有这个模型与自引用外键关系:
class Person(TimeStampedModel):
name = models.CharField(max_length=32)
parent = models.ForeignKey('self', null=True, blank=True, related_name='children')
Run Code Online (Sandbox Code Playgroud)
现在我想为一个人获得所有多层次的孩子.我该如何为它编写Django查询?它需要表现得像递归函数.
我有一个CheckedListBox控件,通过添加DataTemplatea CheckBox到a创建ListView.问题是我也需要列.
以下代码不显示复选框:
<ListView x:Name="lbDatabases" Height="138" Width="498" Canvas.Left="44" Canvas.Top="146">
<ListView.View>
<GridView>
<GridViewColumn DisplayMemberBinding="{Binding DbName}" Header="Databases" Width="498"/>
</GridView>
</ListView.View>
<ListView.ItemTemplate>
<DataTemplate>
<CheckBox IsChecked="{Binding IsActive}" Checked="AnyChange" Unchecked="AnyChange" Style="{x:Null}" Content="{Binding DbName}"
Width="{Binding CheckWidth}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
Run Code Online (Sandbox Code Playgroud)
但是,如果我注释掉这段代码,一切正常,但没有列:
<ListView.View>
<GridView >
<GridViewColumn DisplayMemberBinding="{Binding DbName}" Header="Databases" Width="498"/>
</GridView>
</ListView.View>
Run Code Online (Sandbox Code Playgroud)
有没有办法拥有一切?
我想知道下面的代码是否会被认为是线程安全的.我认为它应该是,但我不太熟悉引擎盖下发生的事情.
基本上,我在类Foo中有这个函数,它将在主线程上调用并将一个向量作为一个anrgument,即
void Foo::func( vector<int> v)
Run Code Online (Sandbox Code Playgroud)
在Foo,我也有一个私人会员,
vector< vector<int> > vecOfVec;
Run Code Online (Sandbox Code Playgroud)
内func,我会简单地推回任何新v上vecOfVec和检查v的规模.如果v小于其预期的大小,我想开始另一个填充了v一些已知的预定值的线程,如此
void Foo::func( vector<int> v)
{
int size = v.size();
int index = vecOfVec.size();
vecOfVec.push_back(v);
if (size < 1000)
{
boost::thread t( boost::bind( &Foo::PushBackZeros, this, vecOfVec, index) );
}
}
Run Code Online (Sandbox Code Playgroud)
Foo::PushBackZeros 就像它的名字所暗示的那样,用'零填充'vecOfVec [index]'的向量,直到它的大小增加到1000;
现在,我没有在任何元素上看到任何并发读或写操作vecOfVec.显然,有可能对整个对象进行并发操作,但永远不会有特定元素的并发vecOfVec.
有人可以解释上述是否会被认为是线程安全的吗?STL地图也同样程度吗?如果没有,请解释.干杯!
所以我在MVC 3 RTM应用程序上编辑了我的csproj文件以设置以下属性:
<MvcBuildViews>true</MvcBuildViews>
Run Code Online (Sandbox Code Playgroud)
这应该导致我的视图在构建期间被编译,并在我的视图被破坏时强制构建错误.这是我做的唯一更改,但是,当我尝试构建应用程序时,出现以下错误:
在应用程序级别之外使用注册为allowDefinition ='MachineToApplication'的部分是错误的.此错误可能是由于未在IIS中将虚拟目录配置为应用程序引起的.
如果我改回false,项目将成功编译并运行
以下是csproj文件中配置的构建任务(这些任务从未手动编辑,它们是由Visual Studio 2010添加的)
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target> -->
<Target Name="MvcBuildViews" AfterTargets="AfterBuild" Condition="'$(MvcBuildViews)'=='true'">
<AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" />
</Target>
Run Code Online (Sandbox Code Playgroud)
我在这里错过了什么吗?如何正确配置MVC 3/Visual Studio 2010以在构建时验证我的视图?
我在我的Mac上安装了Git,但我不知道如何运行它或访问它.从终端我输入git,但它说"命令无效".
我从http://code.google.com/p/git-osx-installer/downloads/list?can=3下载了git, 然后我下载了"Git Installer 1.7.3.5 - OS X - Leopard - x86_64"软件包.
包的内容如下:
当我执行"setup git PATH for non-terminal programs.sh"时,我收到以下消息:
在〜/ .MacOSX/environment.plist中没有改变PATH
~/Volumes/Git 1.7.3.5 x86_64 Leopard/Volumes/Git 1.7.3.5 x86_64 Leopard -MacBook-Pro:Git 1.7.3.5 x86_64 Leopard $ $ PATH -bash:/ usr/local/bin:/ bin:/ sbin:/ usr/bin:/ usr/sbin:/ usr/libexec:没有这样的文件或目录
我的个人资料文件的内容如下:
# System-wide .profile for sh(1)
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
fi
if [ "${BASH-no}" != "no" ]; then
[ -r /etc/bashrc ] && . …Run Code Online (Sandbox Code Playgroud) 我曾多次被要求在SSRS 2008中动态更改文件名.示例:ReportName_201101.RDL.201101代表执行日期.这可以在SSRS 2008中完成吗?
我正在尝试在我的着色器中实现多个灯光但是我无法用我的光数据填充制服.
我的顶点着色器:
attribute vec3 aVertex;
attribute vec3 aNormal;
attribute vec2 aTexture;
uniform mat4 uMVMatrix;
uniform mat4 uPMatrix;
uniform mat4 uNMatrix;
uniform vec3 uAmbientColor;
uniform vec3 uPointLightingLocation[16];
uniform vec3 uPointLightingColor[16];
varying vec2 vTexture;
varying vec3 vLightWeighting;
void main(void) {
vec4 mvPosition = uMVMatrix * vec4(aVertex, 1.0);
gl_Position = uPMatrix * mvPosition;
vTexture = aTexture;
int i;
for (i = 0; i < 16; i++) {
vec3 lightDirection = normalize(uPointLightingLocation[i] - mvPosition.xyz);
vec4 transformedNormal = uNMatrix * vec4(aNormal, 1.0);
float directionalLightWeighting = …Run Code Online (Sandbox Code Playgroud) 我原本打算在我们的网络上使用本地机器作为开发服务器.
然后我有了使用子域的想法.
因此,如果该网站在www.example.com那时开发可以在dev.example.com.
如果我这样做,我会知道整个软件堆栈的配置与开发和生产完全相同.此外,开发可以使用相同的数据库作为生产,消除了同步数据的麻烦.我甚至可以使用相同的媒体(图像,视频等)
我从来没有听说过其他人这样做,而且对于所有这些专业人士,我想知道为什么不呢?
这种方法的缺点是什么?
好的,所以看起来这种方法的主要原因并不是使用相同的数据库来开发和生产.如果你把它排除在等式之外,它仍然是一个糟糕的主意吗?